VirtualBox

Ignore:
Timestamp:
Aug 14, 2024 1:16:30 PM (8 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
164367
Message:

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
29 added
35 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.c

    r99404 r105670  
    14841484
    14851485  @param  This                         Indicates a pointer to the calling context.
    1486   @param  MediaId                      ID of the medium to receive data from.
     1486  @param  MediaId                      ID of the medium to receive data from. If there is no
     1487                                       block IO protocol supported by the physical device, the
     1488                                       value of MediaId is undefined.
    14871489  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    14881490                                       of the security protocol command. A Timeout value of 0
     
    16011603
    16021604  @param  This                         Indicates a pointer to the calling context.
    1603   @param  MediaId                      ID of the medium to receive data from.
     1605  @param  MediaId                      ID of the medium to receive data from. If there is no
     1606                                       block IO protocol supported by the physical device, the
     1607                                       value of MediaId is undefined.
    16041608  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    16051609                                       of the security protocol command. A Timeout value of 0
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaBus.h

    r101291 r105670  
    928928
    929929  @param  This                         Indicates a pointer to the calling context.
    930   @param  MediaId                      ID of the medium to receive data from.
     930  @param  MediaId                      ID of the medium to receive data from. If there is no
     931                                       block IO protocol supported by the physical device, the
     932                                       value of MediaId is undefined.
    931933  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    932934                                       of the security protocol command. A Timeout value of 0
     
    10081010
    10091011  @param  This                         Indicates a pointer to the calling context.
    1010   @param  MediaId                      ID of the medium to receive data from.
     1012  @param  MediaId                      ID of the medium to receive data from. If there is no
     1013                                       block IO protocol supported by the physical device, the
     1014                                       value of MediaId is undefined.
    10111015  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    10121016                                       of the security protocol command. A Timeout value of 0
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c

    r101291 r105670  
    363363    //
    364364    if ((PhyLogicSectorSupport & BIT12) != 0) {
    365       BlockMedia->BlockSize = (UINT32)(((IdentifyData->logic_sector_size_hi << 16) | IdentifyData->logic_sector_size_lo) * sizeof (UINT16));
     365      BlockMedia->BlockSize = (UINT32)(((UINT32)(IdentifyData->logic_sector_size_hi << 16) | IdentifyData->logic_sector_size_lo) * sizeof (UINT16));
    366366    }
    367367
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2KbdTextIn.c

    r99404 r105670  
    259259  @param Key     The output buffer for key value
    260260
    261   @retval EFI_SUCCESS success to read key stroke
     261  @retval EFI_SUCCESS      success to read key stroke
     262  @retval EFI_UNSUPPORTED  The device does not support the ability to read keystroke data.
    262263**/
    263264EFI_STATUS
     
    434435                                  hardware errors.
    435436    @retval EFI_INVALID_PARAMETER KeyData is NULL.
     437    @retval EFI_UNSUPPORTED       The device does not support the ability to read keystroke data.
    436438
    437439**/
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2Keyboard.h

    r99404 r105670  
    339339
    340340  @retval EFI_SUCCESS success to read key stroke
     341  @retval EFI_UNSUPPORTED  The device does not support the ability to read keystroke data.
    341342**/
    342343EFI_STATUS
     
    442443                            hardware errors.
    443444    @retval EFI_INVALID_PARAMETER - KeyData is NULL.
     445    @retval EFI_UNSUPPORTED       - The device does not support the ability to read
     446                            keystroke data.
    444447
    445448**/
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.c

    r101291 r105670  
    17001700
    17011701  @param  This                         Indicates a pointer to the calling context.
    1702   @param  MediaId                      ID of the medium to receive data from.
     1702  @param  MediaId                      ID of the medium to receive data from. If there is no
     1703                                       block IO protocol supported by the physical device, the
     1704                                       value of MediaId is undefined.
    17031705  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    17041706                                       of the security protocol command. A Timeout value of 0
     
    18131815
    18141816  @param  This                         Indicates a pointer to the calling context.
    1815   @param  MediaId                      ID of the medium to receive data from.
     1817  @param  MediaId                      ID of the medium to receive data from. If there is no
     1818                                       block IO protocol supported by the physical device, the
     1819                                       value of MediaId is undefined.
    18161820  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    18171821                                       of the security protocol command. A Timeout value of 0
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressBlockIo.h

    r99404 r105670  
    290290
    291291  @param  This                         Indicates a pointer to the calling context.
    292   @param  MediaId                      ID of the medium to receive data from.
     292  @param  MediaId                      ID of the medium to receive data from. If there is no
     293                                       block IO protocol supported by the physical device, the
     294                                       value of MediaId is undefined.
    293295  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    294296                                       of the security protocol command. A Timeout value of 0
     
    370372
    371373  @param  This                         Indicates a pointer to the calling context.
    372   @param  MediaId                      ID of the medium to receive data from.
     374  @param  MediaId                      ID of the medium to receive data from. If there is no
     375                                       block IO protocol supported by the physical device, the
     376                                       value of MediaId is undefined.
    373377  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    374378                                       of the security protocol command. A Timeout value of 0
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/NvmExpressPei/NvmExpressPeiS3.c

    r99404 r105670  
    6363  }
    6464
    65   if (S3InitDevices == NULL) {
    66     return Skip;
    67   }
    68 
    6965  //
    7066  // Only need to initialize the controllers that exist in the device list.
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c

    r101291 r105670  
    10251025      }
    10261026
    1027       mIoMmuProtocol->SetAttribute (
    1028                         mIoMmuProtocol,
    1029                         PciIoDevice->Handle,
    1030                         *Mapping,
    1031                         IoMmuAttribute
    1032                         );
     1027      Status = mIoMmuProtocol->SetAttribute (
     1028                                 mIoMmuProtocol,
     1029                                 PciIoDevice->Handle,
     1030                                 *Mapping,
     1031                                 IoMmuAttribute
     1032                                 );
    10331033    }
    10341034  }
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c

    r99404 r105670  
    507507    RomImageSize = RomImageSize + RomPcir->ImageLength * 512;
    508508    RomBarOffset = RomBarOffset + RomPcir->ImageLength * 512;
    509   } while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) < RomSize));
     509  } while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) < RomSize) && (RomImageSize > 0));
    510510
    511511  //
     
    513513  // of the legacy length and the PCIR Image Length
    514514  //
    515   if (CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {
     515  if ((RomImageSize > 0) && (CodeType == PCI_CODE_TYPE_PCAT_IMAGE)) {
    516516    RomImageSize = MAX (RomImageSize, LegacyImageLength);
    517517  }
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c

    r99404 r105670  
    198198
    199199/**
    200   Convert the poll rate to the maxium 2^n that is smaller
     200  Convert the poll rate to the maximum 2^n that is smaller
    201201  than Interval.
    202202
     
    214214
    215215  ASSERT (Interval != 0);
     216
     217  //
     218  // To safeguard RELEASE mode wherein ASSERT is effectively not there,
     219  // if inadvertently Interval is still 0 here, treat it the same as 1.
     220  //
     221  if (Interval == 0) {
     222    Interval = 1;
     223  }
    216224
    217225  //
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/UhciDxe/UsbHcMem.c

    r99404 r105670  
    251251
    252252  ASSERT ((Block != NULL));
     253
     254  if (Block == NULL) {
     255    return 0;
     256  }
     257
    253258  //
    254259  // calculate the pci memory address for host memory address.
     
    537542  ASSERT (Block != NULL);
    538543
     544  if (Block == NULL) {
     545    return;
     546  }
     547
    539548  //
    540549  // Release the current memory block if it is empty and not the head
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.c

    r99404 r105670  
    227227  @param  Mem            The pointer to host memory.
    228228  @param  Size           The size of the memory region.
     229  @param  Alignment      Alignment the size to USBHC_MEM_UNIT bytes.
    229230
    230231  @return                The pci memory address
     
    235236  IN USBHC_MEM_POOL  *Pool,
    236237  IN VOID            *Mem,
    237   IN UINTN           Size
     238  IN UINTN           Size,
     239  IN BOOLEAN         Alignment
    238240  )
    239241{
     
    244246  UINTN                 Offset;
    245247
    246   Head      = Pool->Head;
    247   AllocSize = USBHC_MEM_ROUND (Size);
     248  Head = Pool->Head;
     249  if (Alignment) {
     250    AllocSize = USBHC_MEM_ROUND (Size);
     251  } else {
     252    AllocSize = Size;
     253  }
    248254
    249255  if (Mem == NULL) {
     
    276282  @param  Mem            The pointer to pci memory.
    277283  @param  Size           The size of the memory region.
     284  @param  Alignment      Alignment the size to USBHC_MEM_UNIT bytes.
    278285
    279286  @return                The host memory address
     
    284291  IN USBHC_MEM_POOL  *Pool,
    285292  IN VOID            *Mem,
    286   IN UINTN           Size
     293  IN UINTN           Size,
     294  IN BOOLEAN         Alignment
    287295  )
    288296{
     
    293301  UINTN                 Offset;
    294302
    295   Head      = Pool->Head;
    296   AllocSize = USBHC_MEM_ROUND (Size);
     303  Head = Pool->Head;
     304  if (Alignment) {
     305    AllocSize = USBHC_MEM_ROUND (Size);
     306  } else {
     307    AllocSize = Size;
     308  }
    297309
    298310  if (Mem == NULL) {
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/XhciDxe/UsbHcMem.h

    r99404 r105670  
    130130  @param  Mem            The pointer to host memory.
    131131  @param  Size           The size of the memory region.
     132  @param  Alignment      Alignment the size to USBHC_MEM_UNIT bytes.
    132133
    133134  @return                The pci memory address
     
    138139  IN USBHC_MEM_POOL  *Pool,
    139140  IN VOID            *Mem,
    140   IN UINTN           Size
     141  IN UINTN           Size,
     142  IN BOOLEAN         Alignment
    141143  );
    142144
     
    147149  @param  Mem            The pointer to pci memory.
    148150  @param  Size           The size of the memory region.
     151  @param  Alignment      Alignment the size to USBHC_MEM_UNIT bytes.
    149152
    150153  @return                The host memory address
     
    155158  IN USBHC_MEM_POOL  *Pool,
    156159  IN VOID            *Mem,
    157   IN UINTN           Size
     160  IN UINTN           Size,
     161  IN BOOLEAN         Alignment
    158162  );
    159163
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.c

    r101291 r105670  
    22  The XHCI controller driver.
    33
    4 Copyright (c) 2011 - 2022, Intel Corporation. All rights reserved.<BR>
     4(C) Copyright 2023 Hewlett Packard Enterprise Development LP<BR>
     5Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.<BR>
    56SPDX-License-Identifier: BSD-2-Clause-Patent
    67
     
    8586  0x0
    8687};
     88
     89static UINT64   mXhciPerformanceCounterStartValue;
     90static UINT64   mXhciPerformanceCounterEndValue;
     91static UINT64   mXhciPerformanceCounterFrequency;
     92static BOOLEAN  mXhciPerformanceCounterValuesCached = FALSE;
    8793
    8894/**
     
    820826  *DataLength     = Urb->Completed;
    821827
    822   if ((*TransferResult == EFI_USB_ERR_STALL) || (*TransferResult == EFI_USB_ERR_BABBLE)) {
     828  //
     829  // Based on XHCI spec 4.8.3, software should do the reset endpoint while USB Transaction occur.
     830  //
     831  if ((*TransferResult == EFI_USB_ERR_STALL) || (*TransferResult == EFI_USB_ERR_BABBLE) || (*TransferResult == EDKII_USB_ERR_TRANSACTION)) {
    823832    ASSERT (Status == EFI_DEVICE_ERROR);
    824833    RecoveryStatus = XhcRecoverHaltedEndpoint (Xhc, Urb);
     
    22952304  return EFI_SUCCESS;
    22962305}
     2306
     2307/**
     2308  Converts a time in nanoseconds to a performance counter tick count.
     2309
     2310  @param  Time  The time in nanoseconds to be converted to performance counter ticks.
     2311  @return Time in nanoseconds converted to ticks.
     2312**/
     2313UINT64
     2314XhcConvertTimeToTicks (
     2315  IN UINT64  Time
     2316  )
     2317{
     2318  UINT64  Ticks;
     2319  UINT64  Remainder;
     2320  UINT64  Divisor;
     2321  UINTN   Shift;
     2322
     2323  // Cache the return values to avoid repeated calls to GetPerformanceCounterProperties ()
     2324  if (!mXhciPerformanceCounterValuesCached) {
     2325    mXhciPerformanceCounterFrequency = GetPerformanceCounterProperties (
     2326                                         &mXhciPerformanceCounterStartValue,
     2327                                         &mXhciPerformanceCounterEndValue
     2328                                         );
     2329
     2330    mXhciPerformanceCounterValuesCached = TRUE;
     2331  }
     2332
     2333  // Prevent returning a tick value of 0, unless Time is already 0
     2334  if (0 == mXhciPerformanceCounterFrequency) {
     2335    return Time;
     2336  }
     2337
     2338  // Nanoseconds per second
     2339  Divisor = 1000000000;
     2340
     2341  //
     2342  //           Frequency
     2343  // Ticks = ------------- x Time
     2344  //         1,000,000,000
     2345  //
     2346  Ticks = MultU64x64 (
     2347            DivU64x64Remainder (
     2348              mXhciPerformanceCounterFrequency,
     2349              Divisor,
     2350              &Remainder
     2351              ),
     2352            Time
     2353            );
     2354
     2355  //
     2356  // Ensure (Remainder * Time) will not overflow 64-bit.
     2357  //
     2358  // HighBitSet64 (Remainder) + 1 + HighBitSet64 (Time) + 1 <= 64
     2359  //
     2360  Shift     = MAX (0, HighBitSet64 (Remainder) + HighBitSet64 (Time) - 62);
     2361  Remainder = RShiftU64 (Remainder, (UINTN)Shift);
     2362  Divisor   = RShiftU64 (Divisor, (UINTN)Shift);
     2363  Ticks    += DivU64x64Remainder (MultU64x64 (Remainder, Time), Divisor, NULL);
     2364
     2365  return Ticks;
     2366}
     2367
     2368/**
     2369  Computes and returns the elapsed ticks since PreviousTick. The
     2370  value of PreviousTick is overwritten with the current performance
     2371  counter value.
     2372
     2373  @param  PreviousTick    Pointer to PreviousTick count.
     2374  @return The elapsed ticks since PreviousCount. PreviousCount is
     2375          overwritten with the current performance counter value.
     2376**/
     2377UINT64
     2378XhcGetElapsedTicks (
     2379  IN OUT UINT64  *PreviousTick
     2380  )
     2381{
     2382  UINT64  CurrentTick;
     2383  UINT64  Delta;
     2384
     2385  CurrentTick = GetPerformanceCounter ();
     2386
     2387  //
     2388  // Determine if the counter is counting up or down
     2389  //
     2390  if (mXhciPerformanceCounterStartValue < mXhciPerformanceCounterEndValue) {
     2391    //
     2392    // Counter counts upwards, check for an overflow condition
     2393    //
     2394    if (*PreviousTick > CurrentTick) {
     2395      Delta = (mXhciPerformanceCounterEndValue - *PreviousTick) + CurrentTick;
     2396    } else {
     2397      Delta = CurrentTick - *PreviousTick;
     2398    }
     2399  } else {
     2400    //
     2401    // Counter counts downwards, check for an underflow condition
     2402    //
     2403    if (*PreviousTick < CurrentTick) {
     2404      Delta = (mXhciPerformanceCounterStartValue - CurrentTick) + *PreviousTick;
     2405    } else {
     2406      Delta = *PreviousTick - CurrentTick;
     2407    }
     2408  }
     2409
     2410  //
     2411  // Set PreviousTick to CurrentTick
     2412  //
     2413  *PreviousTick = CurrentTick;
     2414
     2415  return Delta;
     2416}
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/XhciDxe/Xhci.h

    r99404 r105670  
    33  Provides some data structure definitions used by the XHCI host controller driver.
    44
     5(C) Copyright 2023 Hewlett Packard Enterprise Development LP<BR>
    56Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
    67Copyright (c) Microsoft Corporation.<BR>
     
    2728#include <Library/DebugLib.h>
    2829#include <Library/ReportStatusCodeLib.h>
     30#include <Library/TimerLib.h>
     31#include <Library/PcdLib.h>
    2932
    3033#include <IndustryStandard/Pci.h>
     
    3740#include "ComponentName.h"
    3841#include "UsbHcMem.h"
     42
     43//
     44// Converts a count from microseconds to nanoseconds
     45//
     46#define XHC_MICROSECOND_TO_NANOSECOND(Time)  (MultU64x32((Time), 1000))
    3947
    4048//
     
    721729  );
    722730
     731/**
     732  Converts a time in nanoseconds to a performance counter tick count.
     733
     734  @param  Time  The time in nanoseconds to be converted to performance counter ticks.
     735  @return Time in nanoseconds converted to ticks.
     736**/
     737UINT64
     738XhcConvertTimeToTicks (
     739  UINT64  Time
     740  );
     741
     742/**
     743  Computes and returns the elapsed ticks since PreviousTick. The
     744  value of PreviousTick is overwritten with the current performance
     745  counter value.
     746
     747  @param  PreviousTick    Pointer to PreviousTick count.
     748  @return The elapsed ticks since PreviousCount. PreviousCount is
     749          overwritten with the current performance counter value.
     750**/
     751UINT64
     752XhcGetElapsedTicks (
     753  IN OUT UINT64  *PreviousTick
     754  );
     755
    723756#endif
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf

    r80721 r105670  
    44#  Control, Bulk, Interrupt and Isochronous requests to those attached usb LS/FS/HS/SS devices.
    55#
     6#  (C) Copyright 2023 Hewlett Packard Enterprise Development LP<BR>
    67#  Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
    78#
     
    4546[Packages]
    4647  MdePkg/MdePkg.dec
     48  MdeModulePkg/MdeModulePkg.dec
    4749
    4850[LibraryClasses]
     
    5557  DebugLib
    5658  ReportStatusCodeLib
     59  TimerLib
     60  PcdLib
    5761
    5862[Guids]
     
    6367  gEfiUsb2HcProtocolGuid                        ## BY_START
    6468
     69[Pcd]
     70  gEfiMdeModulePkgTokenSpaceGuid.PcdDelayXhciHCReset  ## CONSUMES
     71
    6572# [Event]
    6673# EVENT_TYPE_PERIODIC_TIMER       ## CONSUMES
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/XhciDxe/XhciReg.c

    r99404 r105670  
    33  The XHCI register operation routines.
    44
     5(C) Copyright 2023 Hewlett Packard Enterprise Development LP<BR>
    56Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
    67SPDX-License-Identifier: BSD-2-Clause-Patent
     
    418419  to become set (or clear).
    419420
    420   @param  Xhc                    The XHCI Instance.
    421   @param  Offset                 The offset of the operation register.
    422   @param  Bit                    The bit of the register to wait for.
    423   @param  WaitToSet              Wait the bit to set or clear.
    424   @param  Timeout                The time to wait before abort (in millisecond, ms).
    425 
    426   @retval EFI_SUCCESS            The bit successfully changed by host controller.
    427   @retval EFI_TIMEOUT            The time out occurred.
    428   @retval EFI_OUT_OF_RESOURCES   Memory for the timer event could not be allocated.
     421  @param  Xhc          The XHCI Instance.
     422  @param  Offset       The offset of the operation register.
     423  @param  Bit          The bit of the register to wait for.
     424  @param  WaitToSet    Wait the bit to set or clear.
     425  @param  Timeout      The time to wait before abort (in millisecond, ms).
     426
     427  @retval EFI_SUCCESS  The bit successfully changed by host controller.
     428  @retval EFI_TIMEOUT  The time out occurred.
    429429
    430430**/
     
    438438  )
    439439{
    440   EFI_STATUS  Status;
    441   EFI_EVENT   TimeoutEvent;
    442 
    443   TimeoutEvent = NULL;
     440  UINT64  TimeoutTicks;
     441  UINT64  ElapsedTicks;
     442  UINT64  TicksDelta;
     443  UINT64  CurrentTick;
    444444
    445445  if (Timeout == 0) {
     
    447447  }
    448448
    449   Status = gBS->CreateEvent (
    450                   EVT_TIMER,
    451                   TPL_CALLBACK,
    452                   NULL,
    453                   NULL,
    454                   &TimeoutEvent
    455                   );
    456 
    457   if (EFI_ERROR (Status)) {
    458     goto DONE;
    459   }
    460 
    461   Status = gBS->SetTimer (
    462                   TimeoutEvent,
    463                   TimerRelative,
    464                   EFI_TIMER_PERIOD_MILLISECONDS (Timeout)
    465                   );
    466 
    467   if (EFI_ERROR (Status)) {
    468     goto DONE;
    469   }
    470 
     449  TimeoutTicks = XhcConvertTimeToTicks (XHC_MICROSECOND_TO_NANOSECOND (Timeout * XHC_1_MILLISECOND));
     450  ElapsedTicks = 0;
     451  CurrentTick  = GetPerformanceCounter ();
    471452  do {
    472453    if (XHC_REG_BIT_IS_SET (Xhc, Offset, Bit) == WaitToSet) {
    473       Status = EFI_SUCCESS;
    474       goto DONE;
     454      return EFI_SUCCESS;
    475455    }
    476456
    477457    gBS->Stall (XHC_1_MICROSECOND);
    478   } while (EFI_ERROR (gBS->CheckEvent (TimeoutEvent)));
    479 
    480   Status = EFI_TIMEOUT;
    481 
    482 DONE:
    483   if (TimeoutEvent != NULL) {
    484     gBS->CloseEvent (TimeoutEvent);
    485   }
    486 
    487   return Status;
     458    TicksDelta = XhcGetElapsedTicks (&CurrentTick);
     459    // Ensure that ElapsedTicks is always incremented to avoid indefinite hangs
     460    if (TicksDelta == 0) {
     461      TicksDelta = XhcConvertTimeToTicks (XHC_MICROSECOND_TO_NANOSECOND (XHC_1_MICROSECOND));
     462    }
     463
     464    ElapsedTicks += TicksDelta;
     465  } while (ElapsedTicks < TimeoutTicks);
     466
     467  return EFI_TIMEOUT;
    488468}
    489469
     
    885865    // The below is a workaround to solve such problem.
    886866    //
    887     gBS->Stall (XHC_1_MILLISECOND);
     867    gBS->Stall (PcdGet16 (PcdDelayXhciHCReset));
    888868    Status = XhcWaitOpRegBit (Xhc, XHC_USBCMD_OFFSET, XHC_USBCMD_RESET, FALSE, Timeout);
    889869
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c

    r101291 r105670  
    33  XHCI transfer scheduling routines.
    44
     5(C) Copyright 2023 Hewlett Packard Enterprise Development LP<BR>
    56Copyright (c) 2011 - 2020, Intel Corporation. All rights reserved.<BR>
    67Copyright (c) Microsoft Corporation.<BR>
     
    589590  // So divide it to two 32-bytes width register access.
    590591  //
    591   DcbaaPhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Dcbaa, Entries);
     592  DcbaaPhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Dcbaa, Entries, TRUE);
    592593  XhcWriteOpReg (Xhc, XHC_DCBAAP_OFFSET, XHC_LOW_32BIT (DcbaaPhy));
    593594  XhcWriteOpReg (Xhc, XHC_DCBAAP_OFFSET + 4, XHC_HIGH_32BIT (DcbaaPhy));
     
    608609  //
    609610  CmdRing    = (UINT64)(UINTN)Xhc->CmdRing.RingSeg0;
    610   CmdRingPhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, (VOID *)(UINTN)CmdRing, sizeof (TRB_TEMPLATE) * CMD_RING_TRB_NUMBER);
     611  CmdRingPhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, (VOID *)(UINTN)CmdRing, sizeof (TRB_TEMPLATE) * CMD_RING_TRB_NUMBER, TRUE);
    611612  ASSERT ((CmdRingPhy & 0x3F) == 0);
    612613  CmdRingPhy |= XHC_CRCR_RCS;
     
    810811  EventRing->EventRingEnqueue = (TRB_TEMPLATE *)EventRing->EventRingSeg0;
    811812
    812   DequeuePhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Buf, Size);
     813  DequeuePhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Buf, Size, TRUE);
    813814
    814815  //
     
    830831  ERSTBase->RingTrbSize = EVENT_RING_TRB_NUMBER;
    831832
    832   ERSTPhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, ERSTBase, Size);
     833  ERSTPhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, ERSTBase, Size, TRUE);
    833834
    834835  //
     
    914915  EndTrb        = (LINK_TRB *)((UINTN)Buf + sizeof (TRB_TEMPLATE) * (TrbNum - 1));
    915916  EndTrb->Type  = TRB_TYPE_LINK;
    916   PhyAddr       = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Buf, sizeof (TRB_TEMPLATE) * TrbNum);
     917  PhyAddr       = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Buf, sizeof (TRB_TEMPLATE) * TrbNum, TRUE);
    917918  EndTrb->PtrLo = XHC_LOW_32BIT (PhyAddr);
    918919  EndTrb->PtrHi = XHC_HIGH_32BIT (PhyAddr);
     
    10461047      LinkTrb    = (LINK_TRB *)CheckedTrb;
    10471048      PhyAddr    = (EFI_PHYSICAL_ADDRESS)(LinkTrb->PtrLo | LShiftU64 ((UINT64)LinkTrb->PtrHi, 32));
    1048       CheckedTrb = (TRB_TEMPLATE *)(UINTN)UsbHcGetHostAddrForPciAddr (Xhc->MemPool, (VOID *)(UINTN)PhyAddr, sizeof (TRB_TEMPLATE));
     1049      CheckedTrb = (TRB_TEMPLATE *)(UINTN)UsbHcGetHostAddrForPciAddr (Xhc->MemPool, (VOID *)(UINTN)PhyAddr, sizeof (TRB_TEMPLATE), FALSE);
    10491050      ASSERT (CheckedTrb == Urb->Ring->RingSeg0);
    10501051    }
     
    11551156    //
    11561157    PhyAddr = (EFI_PHYSICAL_ADDRESS)(EvtTrb->TRBPtrLo | LShiftU64 ((UINT64)EvtTrb->TRBPtrHi, 32));
    1157     TRBPtr  = (TRB_TEMPLATE *)(UINTN)UsbHcGetHostAddrForPciAddr (Xhc->MemPool, (VOID *)(UINTN)PhyAddr, sizeof (TRB_TEMPLATE));
     1158    TRBPtr  = (TRB_TEMPLATE *)(UINTN)UsbHcGetHostAddrForPciAddr (Xhc->MemPool, (VOID *)(UINTN)PhyAddr, sizeof (TRB_TEMPLATE), FALSE);
    11581159
    11591160    //
     
    11921193        goto EXIT;
    11931194
     1195      //
     1196      // Based on XHCI spec 4.8.3, software should do the reset endpoint while USB Transaction occur.
     1197      //
    11941198      case TRB_COMPLETION_USB_TRANSACTION_ERROR:
    1195         CheckedUrb->Result  |= EFI_USB_ERR_TIMEOUT;
     1199        CheckedUrb->Result  |= EDKII_USB_ERR_TRANSACTION;
    11961200        CheckedUrb->Finished = TRUE;
    11971201        DEBUG ((DEBUG_ERROR, "XhcCheckUrbResult: TRANSACTION_ERROR! Completecode = %x\n", EvtTrb->Completecode));
     
    12601264  XhcDequeue = (UINT64)(LShiftU64 ((UINT64)High, 32) | Low);
    12611265
    1262   PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->EventRing.EventRingDequeue, sizeof (TRB_TEMPLATE));
     1266  PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->EventRing.EventRingDequeue, sizeof (TRB_TEMPLATE), FALSE);
    12631267
    12641268  if ((XhcDequeue & (~0x0F)) != (PhyAddr & (~0x0F))) {
     
    12771281  Execute the transfer by polling the URB. This is a synchronous operation.
    12781282
    1279   @param  Xhc                    The XHCI Instance.
    1280   @param  CmdTransfer            The executed URB is for cmd transfer or not.
    1281   @param  Urb                    The URB to execute.
    1282   @param  Timeout                The time to wait before abort, in millisecond.
    1283 
    1284   @return EFI_DEVICE_ERROR       The transfer failed due to transfer error.
    1285   @return EFI_TIMEOUT            The transfer failed due to time out.
    1286   @return EFI_SUCCESS            The transfer finished OK.
    1287   @retval EFI_OUT_OF_RESOURCES   Memory for the timer event could not be allocated.
     1283  @param  Xhc               The XHCI Instance.
     1284  @param  CmdTransfer       The executed URB is for cmd transfer or not.
     1285  @param  Urb               The URB to execute.
     1286  @param  Timeout           The time to wait before abort, in millisecond.
     1287
     1288  @return EFI_DEVICE_ERROR  The transfer failed due to transfer error.
     1289  @return EFI_TIMEOUT       The transfer failed due to time out.
     1290  @return EFI_SUCCESS       The transfer finished OK.
    12881291
    12891292**/
     
    13001303  UINT8       Dci;
    13011304  BOOLEAN     Finished;
    1302   EFI_EVENT   TimeoutEvent;
     1305  UINT64      TimeoutTicks;
     1306  UINT64      ElapsedTicks;
     1307  UINT64      TicksDelta;
     1308  UINT64      CurrentTick;
    13031309  BOOLEAN     IndefiniteTimeout;
    13041310
    13051311  Status            = EFI_SUCCESS;
    13061312  Finished          = FALSE;
    1307   TimeoutEvent      = NULL;
    13081313  IndefiniteTimeout = FALSE;
    13091314
     
    13231328  if (Timeout == 0) {
    13241329    IndefiniteTimeout = TRUE;
    1325     goto RINGDOORBELL;
    1326   }
    1327 
    1328   Status = gBS->CreateEvent (
    1329                   EVT_TIMER,
    1330                   TPL_CALLBACK,
    1331                   NULL,
    1332                   NULL,
    1333                   &TimeoutEvent
    1334                   );
    1335 
    1336   if (EFI_ERROR (Status)) {
    1337     goto DONE;
    1338   }
    1339 
    1340   Status = gBS->SetTimer (
    1341                   TimeoutEvent,
    1342                   TimerRelative,
    1343                   EFI_TIMER_PERIOD_MILLISECONDS (Timeout)
    1344                   );
    1345 
    1346   if (EFI_ERROR (Status)) {
    1347     goto DONE;
    1348   }
    1349 
    1350 RINGDOORBELL:
     1330  }
     1331
    13511332  XhcRingDoorBell (Xhc, SlotId, Dci);
     1333
     1334  TimeoutTicks = XhcConvertTimeToTicks (
     1335                   XHC_MICROSECOND_TO_NANOSECOND (
     1336                     Timeout * XHC_1_MILLISECOND
     1337                     )
     1338                   );
     1339  ElapsedTicks = 0;
     1340  CurrentTick  = GetPerformanceCounter ();
    13521341
    13531342  do {
     
    13581347
    13591348    gBS->Stall (XHC_1_MICROSECOND);
    1360   } while (IndefiniteTimeout || EFI_ERROR (gBS->CheckEvent (TimeoutEvent)));
    1361 
    1362 DONE:
    1363   if (EFI_ERROR (Status)) {
    1364     Urb->Result = EFI_USB_ERR_NOTEXECUTE;
    1365   } else if (!Finished) {
     1349    TicksDelta = XhcGetElapsedTicks (&CurrentTick);
     1350    // Ensure that ElapsedTicks is always incremented to avoid indefinite hangs
     1351    if (TicksDelta == 0) {
     1352      TicksDelta = XhcConvertTimeToTicks (XHC_MICROSECOND_TO_NANOSECOND (XHC_1_MICROSECOND));
     1353    }
     1354
     1355    ElapsedTicks += TicksDelta;
     1356  } while (IndefiniteTimeout || ElapsedTicks < TimeoutTicks);
     1357
     1358  if (!Finished) {
    13661359    Urb->Result = EFI_USB_ERR_TIMEOUT;
    13671360    Status      = EFI_TIMEOUT;
    13681361  } else if (Urb->Result != EFI_USB_NOERROR) {
    13691362    Status = EFI_DEVICE_ERROR;
    1370   }
    1371 
    1372   if (TimeoutEvent != NULL) {
    1373     gBS->CloseEvent (TimeoutEvent);
    13741363  }
    13751364
     
    21232112
    21242113/**
     2114  Set Command abort
     2115
     2116  @param  Xhc           The XHCI Instance.
     2117  @param  SlotId        The slot id to be disabled.
     2118
     2119**/
     2120VOID
     2121XhcCmdRingCmdAbort (
     2122  IN USB_XHCI_INSTANCE  *Xhc,
     2123  IN UINT8              SlotId
     2124  )
     2125{
     2126  //
     2127  // Set XHC_CRCR_CA bit in XHC_CRCR_OFFSET to abort command.
     2128  //
     2129  DEBUG ((DEBUG_INFO, "Command Ring Control set Command Abort, SlotId: %d\n", SlotId));
     2130  XhcSetOpRegBit (Xhc, XHC_CRCR_OFFSET, XHC_CRCR_CA);
     2131}
     2132
     2133/**
    21252134  Assign and initialize the device slot for a new device.
    21262135
     
    22812290              Xhc->MemPool,
    22822291              ((TRANSFER_RING *)(UINTN)Xhc->UsbDevContext[SlotId].EndpointTransferRing[0])->RingSeg0,
    2283               sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER
     2292              sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER,
     2293              TRUE
    22842294              );
    22852295  InputContext->EP[0].PtrLo = XHC_LOW_32BIT (PhyAddr) | BIT0;
     
    22992309  //    a pointer to the Output Device Context data structure (6.2.1).
    23002310  //
    2301   PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, OutputContext, sizeof (DEVICE_CONTEXT));
     2311  PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, OutputContext, sizeof (DEVICE_CONTEXT), TRUE);
    23022312  //
    23032313  // Fill DCBAA with PCI device address
     
    23142324  gBS->Stall (XHC_RESET_RECOVERY_DELAY);
    23152325  ZeroMem (&CmdTrbAddr, sizeof (CmdTrbAddr));
    2316   PhyAddr             = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->UsbDevContext[SlotId].InputContext, sizeof (INPUT_CONTEXT));
     2326  PhyAddr             = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->UsbDevContext[SlotId].InputContext, sizeof (INPUT_CONTEXT), TRUE);
    23172327  CmdTrbAddr.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    23182328  CmdTrbAddr.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    23322342  } else {
    23332343    DEBUG ((DEBUG_ERROR, "    Slot %d address not assigned successfully. Status = %r\n", SlotId, Status));
     2344    //
     2345    // Software may abort the execution of Address Device Command when command failed
     2346    // due to timeout by following XHCI spec. 4.6.1.2.
     2347    //
     2348    if (Status == EFI_TIMEOUT) {
     2349      XhcCmdRingCmdAbort (Xhc, SlotId);
     2350    }
     2351
    23342352    XhcDisableSlotCmd (Xhc, SlotId);
    23352353  }
     
    24972515              Xhc->MemPool,
    24982516              ((TRANSFER_RING *)(UINTN)Xhc->UsbDevContext[SlotId].EndpointTransferRing[0])->RingSeg0,
    2499               sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER
     2517              sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER,
     2518              TRUE
    25002519              );
    25012520  InputContext->EP[0].PtrLo = XHC_LOW_32BIT (PhyAddr) | BIT0;
     
    25152534  //    a pointer to the Output Device Context data structure (6.2.1).
    25162535  //
    2517   PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, OutputContext, sizeof (DEVICE_CONTEXT_64));
     2536  PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, OutputContext, sizeof (DEVICE_CONTEXT_64), TRUE);
    25182537  //
    25192538  // Fill DCBAA with PCI device address
     
    25302549  gBS->Stall (XHC_RESET_RECOVERY_DELAY);
    25312550  ZeroMem (&CmdTrbAddr, sizeof (CmdTrbAddr));
    2532   PhyAddr             = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->UsbDevContext[SlotId].InputContext, sizeof (INPUT_CONTEXT_64));
     2551  PhyAddr             = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->UsbDevContext[SlotId].InputContext, sizeof (INPUT_CONTEXT_64), TRUE);
    25332552  CmdTrbAddr.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    25342553  CmdTrbAddr.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    25482567  } else {
    25492568    DEBUG ((DEBUG_ERROR, "    Slot %d address not assigned successfully. Status = %r\n", SlotId, Status));
     2569    //
     2570    // Software may abort the execution of Address Device Command when command failed
     2571    // due to timeout by following XHCI spec. 4.6.1.2.
     2572    //
     2573    if (Status == EFI_TIMEOUT) {
     2574      XhcCmdRingCmdAbort (Xhc, SlotId);
     2575    }
     2576
    25502577    XhcDisableSlotCmd64 (Xhc, SlotId);
    25512578  }
     
    29652992                Xhc->MemPool,
    29662993                ((TRANSFER_RING *)(UINTN)Xhc->UsbDevContext[SlotId].EndpointTransferRing[Dci-1])->RingSeg0,
    2967                 sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER
     2994                sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER,
     2995                TRUE
    29682996                );
    29692997    PhyAddr                      &= ~((EFI_PHYSICAL_ADDRESS)0x0F);
     
    31673195                Xhc->MemPool,
    31683196                ((TRANSFER_RING *)(UINTN)Xhc->UsbDevContext[SlotId].EndpointTransferRing[Dci-1])->RingSeg0,
    3169                 sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER
     3197                sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER,
     3198                TRUE
    31703199                );
    31713200    PhyAddr                      &= ~((EFI_PHYSICAL_ADDRESS)0x0F);
     
    32493278  //
    32503279  ZeroMem (&CmdTrbCfgEP, sizeof (CmdTrbCfgEP));
    3251   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT));
     3280  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT), TRUE);
    32523281  CmdTrbCfgEP.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    32533282  CmdTrbCfgEP.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    33403369  //
    33413370  ZeroMem (&CmdTrbCfgEP, sizeof (CmdTrbCfgEP));
    3342   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64));
     3371  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64), TRUE);
    33433372  CmdTrbCfgEP.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    33443373  CmdTrbCfgEP.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    35143543  //
    35153544  ZeroMem (&CmdSetTRDeq, sizeof (CmdSetTRDeq));
    3516   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Urb->Ring->RingEnqueue, sizeof (CMD_SET_TR_DEQ_POINTER));
     3545  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Urb->Ring->RingEnqueue, sizeof (CMD_SET_TR_DEQ_POINTER), FALSE);
    35173546  CmdSetTRDeq.PtrLo    = XHC_LOW_32BIT (PhyAddr) | Urb->Ring->RingPCS;
    35183547  CmdSetTRDeq.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    37143743    //
    37153744    ZeroMem (&CmdTrbCfgEP, sizeof (CmdTrbCfgEP));
    3716     PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT));
     3745    PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT), TRUE);
    37173746    CmdTrbCfgEP.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    37183747    CmdTrbCfgEP.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    39203949    //
    39213950    ZeroMem (&CmdTrbCfgEP, sizeof (CmdTrbCfgEP));
    3922     PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64));
     3951    PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64), TRUE);
    39233952    CmdTrbCfgEP.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    39243953    CmdTrbCfgEP.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    39874016
    39884017  ZeroMem (&CmdTrbEvalu, sizeof (CmdTrbEvalu));
    3989   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT));
     4018  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT), TRUE);
    39904019  CmdTrbEvalu.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    39914020  CmdTrbEvalu.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    40484077
    40494078  ZeroMem (&CmdTrbEvalu, sizeof (CmdTrbEvalu));
    4050   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64));
     4079  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64), TRUE);
    40514080  CmdTrbEvalu.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    40524081  CmdTrbEvalu.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    41174146
    41184147  ZeroMem (&CmdTrbCfgEP, sizeof (CmdTrbCfgEP));
    4119   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT));
     4148  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT), TRUE);
    41204149  CmdTrbCfgEP.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    41214150  CmdTrbCfgEP.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    41864215
    41874216  ZeroMem (&CmdTrbCfgEP, sizeof (CmdTrbCfgEP));
    4188   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64));
     4217  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64), TRUE);
    41894218  CmdTrbCfgEP.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    41904219  CmdTrbCfgEP.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h

    r99404 r105670  
    8080
    8181//
     82// USB Transfer Results Internal Definition
     83// Based on XHCI spec 4.8.3, software should do the reset endpoint while USB Transaction occur.
     84// Add the error code for USB Transaction error since UEFI spec don't have the related definition.
     85//
     86#define EDKII_USB_ERR_TRANSACTION  0x200
     87
     88//
    8289// The topology string used to present usb device location
    8390//
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c

    r99404 r105670  
    191191  @param  Mem           The pointer to host memory.
    192192  @param  Size          The size of the memory region.
     193  @param  Alignment     Alignment the size to USBHC_MEM_UNIT bytes.
    193194
    194195  @return               The pci memory address
     
    199200  IN USBHC_MEM_POOL  *Pool,
    200201  IN VOID            *Mem,
    201   IN UINTN           Size
     202  IN UINTN           Size,
     203  IN BOOLEAN         Alignment
    202204  )
    203205{
     
    208210  UINTN                 Offset;
    209211
    210   Head      = Pool->Head;
    211   AllocSize = USBHC_MEM_ROUND (Size);
     212  Head = Pool->Head;
     213  if (Alignment) {
     214    AllocSize = USBHC_MEM_ROUND (Size);
     215  } else {
     216    AllocSize = Size;
     217  }
    212218
    213219  if (Mem == NULL) {
     
    240246  @param  Mem           The pointer to pci memory.
    241247  @param  Size          The size of the memory region.
     248  @param  Alignment     Alignment the size to USBHC_MEM_UNIT bytes.
    242249
    243250  @return               The host memory address
     
    248255  IN USBHC_MEM_POOL  *Pool,
    249256  IN VOID            *Mem,
    250   IN UINTN           Size
     257  IN UINTN           Size,
     258  IN BOOLEAN         Alignment
    251259  )
    252260{
     
    257265  UINTN                 Offset;
    258266
    259   Head      = Pool->Head;
    260   AllocSize = USBHC_MEM_ROUND (Size);
     267  Head = Pool->Head;
     268  if (Alignment) {
     269    AllocSize = USBHC_MEM_ROUND (Size);
     270  } else {
     271    AllocSize = Size;
     272  }
    261273
    262274  if (Mem == NULL) {
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.h

    r99404 r105670  
    6969  @param  Mem           The pointer to host memory.
    7070  @param  Size          The size of the memory region.
     71  @param  Alignment     Alignment the size to USBHC_MEM_UNIT bytes.
    7172
    7273  @return               The pci memory address
     
    7778  IN USBHC_MEM_POOL  *Pool,
    7879  IN VOID            *Mem,
    79   IN UINTN           Size
     80  IN UINTN           Size,
     81  IN BOOLEAN         Alignment
    8082  );
    8183
     
    8688  @param  Mem           The pointer to pci memory.
    8789  @param  Size          The size of the memory region.
     90  @param  Alignment     Alignment the size to USBHC_MEM_UNIT bytes.
    8891
    8992  @return               The host memory address
     
    9497  IN USBHC_MEM_POOL  *Pool,
    9598  IN VOID            *Mem,
    96   IN UINTN           Size
     99  IN UINTN           Size,
     100  IN BOOLEAN         Alignment
    97101  );
    98102
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c

    r99404 r105670  
    676676    //
    677677    PhyAddr = (EFI_PHYSICAL_ADDRESS)(EvtTrb->TRBPtrLo | LShiftU64 ((UINT64)EvtTrb->TRBPtrHi, 32));
    678     TRBPtr  = (TRB_TEMPLATE *)(UINTN)UsbHcGetHostAddrForPciAddr (Xhc->MemPool, (VOID *)(UINTN)PhyAddr, sizeof (TRB_TEMPLATE));
     678    TRBPtr  = (TRB_TEMPLATE *)(UINTN)UsbHcGetHostAddrForPciAddr (Xhc->MemPool, (VOID *)(UINTN)PhyAddr, sizeof (TRB_TEMPLATE), FALSE);
    679679
    680680    //
     
    767767  XhcDequeue = (UINT64)(LShiftU64 ((UINT64)High, 32) | Low);
    768768
    769   PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->EventRing.EventRingDequeue, sizeof (TRB_TEMPLATE));
     769  PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->EventRing.EventRingDequeue, sizeof (TRB_TEMPLATE), FALSE);
    770770
    771771  if ((XhcDequeue & (~0x0F)) != (PhyAddr & (~0x0F))) {
     
    12141214              Xhc->MemPool,
    12151215              ((TRANSFER_RING *)(UINTN)Xhc->UsbDevContext[SlotId].EndpointTransferRing[0])->RingSeg0,
    1216               sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER
     1216              sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER,
     1217              TRUE
    12171218              );
    12181219  InputContext->EP[0].PtrLo = XHC_LOW_32BIT (PhyAddr) | BIT0;
     
    12321233  //    a pointer to the Output Device Context data structure (6.2.1).
    12331234  //
    1234   PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, OutputContext, sizeof (DEVICE_CONTEXT));
     1235  PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, OutputContext, sizeof (DEVICE_CONTEXT), TRUE);
    12351236  //
    12361237  // Fill DCBAA with PCI device address
     
    12471248  MicroSecondDelay (XHC_RESET_RECOVERY_DELAY);
    12481249  ZeroMem (&CmdTrbAddr, sizeof (CmdTrbAddr));
    1249   PhyAddr             = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->UsbDevContext[SlotId].InputContext, sizeof (INPUT_CONTEXT));
     1250  PhyAddr             = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->UsbDevContext[SlotId].InputContext, sizeof (INPUT_CONTEXT), TRUE);
    12501251  CmdTrbAddr.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    12511252  CmdTrbAddr.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    14281429              Xhc->MemPool,
    14291430              ((TRANSFER_RING *)(UINTN)Xhc->UsbDevContext[SlotId].EndpointTransferRing[0])->RingSeg0,
    1430               sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER
     1431              sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER,
     1432              TRUE
    14311433              );
    14321434  InputContext->EP[0].PtrLo = XHC_LOW_32BIT (PhyAddr) | BIT0;
     
    14461448  //    a pointer to the Output Device Context data structure (6.2.1).
    14471449  //
    1448   PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, OutputContext, sizeof (DEVICE_CONTEXT_64));
     1450  PhyAddr = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, OutputContext, sizeof (DEVICE_CONTEXT_64), TRUE);
    14491451  //
    14501452  // Fill DCBAA with PCI device address
     
    14611463  MicroSecondDelay (XHC_RESET_RECOVERY_DELAY);
    14621464  ZeroMem (&CmdTrbAddr, sizeof (CmdTrbAddr));
    1463   PhyAddr             = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->UsbDevContext[SlotId].InputContext, sizeof (INPUT_CONTEXT_64));
     1465  PhyAddr             = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->UsbDevContext[SlotId].InputContext, sizeof (INPUT_CONTEXT_64), TRUE);
    14641466  CmdTrbAddr.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    14651467  CmdTrbAddr.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    18831885                  Xhc->MemPool,
    18841886                  ((TRANSFER_RING *)(UINTN)Xhc->UsbDevContext[SlotId].EndpointTransferRing[Dci-1])->RingSeg0,
    1885                   sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER
     1887                  sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER,
     1888                  TRUE
    18861889                  );
    18871890      PhyAddr                      &= ~((EFI_PHYSICAL_ADDRESS)0x0F);
     
    19021905  //
    19031906  ZeroMem (&CmdTrbCfgEP, sizeof (CmdTrbCfgEP));
    1904   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT));
     1907  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT), TRUE);
    19051908  CmdTrbCfgEP.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    19061909  CmdTrbCfgEP.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    21092112                  Xhc->MemPool,
    21102113                  ((TRANSFER_RING *)(UINTN)Xhc->UsbDevContext[SlotId].EndpointTransferRing[Dci-1])->RingSeg0,
    2111                   sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER
     2114                  sizeof (TRB_TEMPLATE) * TR_RING_TRB_NUMBER,
     2115                  TRUE
    21122116                  );
    21132117
     
    21302134  //
    21312135  ZeroMem (&CmdTrbCfgEP, sizeof (CmdTrbCfgEP));
    2132   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64));
     2136  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64), TRUE);
    21332137  CmdTrbCfgEP.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    21342138  CmdTrbCfgEP.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    21852189
    21862190  ZeroMem (&CmdTrbEvalu, sizeof (CmdTrbEvalu));
    2187   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT));
     2191  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT), TRUE);
    21882192  CmdTrbEvalu.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    21892193  CmdTrbEvalu.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    22402244
    22412245  ZeroMem (&CmdTrbEvalu, sizeof (CmdTrbEvalu));
    2242   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64));
     2246  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64), TRUE);
    22432247  CmdTrbEvalu.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    22442248  CmdTrbEvalu.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    23092313
    23102314  ZeroMem (&CmdTrbCfgEP, sizeof (CmdTrbCfgEP));
    2311   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT));
     2315  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT), TRUE);
    23122316  CmdTrbCfgEP.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    23132317  CmdTrbCfgEP.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    23782382
    23792383  ZeroMem (&CmdTrbCfgEP, sizeof (CmdTrbCfgEP));
    2380   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64));
     2384  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, InputContext, sizeof (INPUT_CONTEXT_64), TRUE);
    23812385  CmdTrbCfgEP.PtrLo    = XHC_LOW_32BIT (PhyAddr);
    23822386  CmdTrbCfgEP.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    25232527  //
    25242528  ZeroMem (&CmdSetTRDeq, sizeof (CmdSetTRDeq));
    2525   PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Urb->Ring->RingEnqueue, sizeof (CMD_SET_TR_DEQ_POINTER));
     2529  PhyAddr              = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Urb->Ring->RingEnqueue, sizeof (CMD_SET_TR_DEQ_POINTER), FALSE);
    25262530  CmdSetTRDeq.PtrLo    = XHC_LOW_32BIT (PhyAddr) | Urb->Ring->RingPCS;
    25272531  CmdSetTRDeq.PtrHi    = XHC_HIGH_32BIT (PhyAddr);
     
    26832687  ZeroMem (Buf, Size);
    26842688
    2685   DequeuePhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Buf, Size);
     2689  DequeuePhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Buf, Size, TRUE);
    26862690
    26872691  EventRing->EventRingSeg0    = Buf;
     
    27082712  ERSTBase->RingTrbSize = EVENT_RING_TRB_NUMBER;
    27092713
    2710   ERSTPhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Buf, Size);
     2714  ERSTPhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Buf, Size, TRUE);
    27112715
    27122716  //
     
    28562860  EndTrb        = (LINK_TRB *)((UINTN)Buf + sizeof (TRB_TEMPLATE) * (TrbNum - 1));
    28572861  EndTrb->Type  = TRB_TYPE_LINK;
    2858   PhyAddr       = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Buf, sizeof (TRB_TEMPLATE) * TrbNum);
     2862  PhyAddr       = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Buf, sizeof (TRB_TEMPLATE) * TrbNum, TRUE);
    28592863  EndTrb->PtrLo = XHC_LOW_32BIT (PhyAddr);
    28602864  EndTrb->PtrHi = XHC_HIGH_32BIT (PhyAddr);
     
    29892993  // So divide it to two 32-bytes width register access.
    29902994  //
    2991   DcbaaPhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Dcbaa, Size);
     2995  DcbaaPhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Dcbaa, Size, TRUE);
    29922996  XhcPeiWriteOpReg (Xhc, XHC_DCBAAP_OFFSET, XHC_LOW_32BIT (DcbaaPhy));
    29932997  XhcPeiWriteOpReg (Xhc, XHC_DCBAAP_OFFSET + 4, XHC_HIGH_32BIT (DcbaaPhy));
     
    30073011  // So we set RCS as inverted PCS init value to let Command Ring empty
    30083012  //
    3009   CmdRingPhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->CmdRing.RingSeg0, sizeof (TRB_TEMPLATE) * CMD_RING_TRB_NUMBER);
     3013  CmdRingPhy = UsbHcGetPciAddrForHostAddr (Xhc->MemPool, Xhc->CmdRing.RingSeg0, sizeof (TRB_TEMPLATE) * CMD_RING_TRB_NUMBER, TRUE);
    30103014  ASSERT ((CmdRingPhy & 0x3F) == 0);
    30113015  CmdRingPhy |= XHC_CRCR_RCS;
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c

    r101291 r105670  
    18981898
    18991899  @param  This                         Indicates a pointer to the calling context.
    1900   @param  MediaId                      ID of the medium to receive data from.
     1900  @param  MediaId                      ID of the medium to receive data from. If there is no
     1901                                       block IO protocol supported by the physical device, the
     1902                                       value of MediaId is undefined.
    19011903  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    19021904                                       of the security protocol command. A Timeout value of 0
     
    21202122
    21212123  @param  This                         Indicates a pointer to the calling context.
    2122   @param  MediaId                      ID of the medium to receive data from.
     2124  @param  MediaId                      ID of the medium to receive data from. If there is no
     2125                                       block IO protocol supported by the physical device, the
     2126                                       value of MediaId is undefined.
    21232127  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    21242128                                       of the security protocol command. A Timeout value of 0
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h

    r101291 r105670  
    678678
    679679  @param  This                         Indicates a pointer to the calling context.
    680   @param  MediaId                      ID of the medium to receive data from.
     680  @param  MediaId                      ID of the medium to receive data from. If there is no
     681                                       block IO protocol supported by the physical device, the
     682                                       value of MediaId is undefined.
    681683  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    682684                                       of the security protocol command. A Timeout value of 0
     
    752754
    753755  @param  This                         Indicates a pointer to the calling context.
    754   @param  MediaId                      ID of the medium to receive data from.
     756  @param  MediaId                      ID of the medium to receive data from. If there is no
     757                                       block IO protocol supported by the physical device, the
     758                                       value of MediaId is undefined.
    755759  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    756760                                       of the security protocol command. A Timeout value of 0
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.c

    r99404 r105670  
    12681268
    12691269  @param[in]  This                         Indicates a pointer to the calling context.
    1270   @param[in]  MediaId                      ID of the medium to receive data from.
     1270  @param[in]  MediaId                      ID of the medium to receive data from. If there is no
     1271                                           block IO protocol supported by the physical device, the
     1272                                           value of MediaId is undefined.
    12711273  @param[in]  Timeout                      The timeout, in 100ns units, to use for the execution
    12721274                                           of the security protocol command. A Timeout value of 0
     
    14551457
    14561458  @param  This                         Indicates a pointer to the calling context.
    1457   @param  MediaId                      ID of the medium to receive data from.
     1459  @param  MediaId                      ID of the medium to receive data from. If there is no
     1460                                       block IO protocol supported by the physical device, the
     1461                                       value of MediaId is undefined.
    14581462  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    14591463                                       of the security protocol command. A Timeout value of 0
     
    15561560
    15571561  @param  This                         Indicates a pointer to the calling context.
    1558   @param  MediaId                      ID of the medium to receive data from.
     1562  @param  MediaId                      ID of the medium to receive data from. If there is no
     1563                                       block IO protocol supported by the physical device, the
     1564                                       value of MediaId is undefined.
    15591565  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    15601566                                       of the security protocol command. A Timeout value of 0
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Sd/EmmcDxe/EmmcBlockIo.h

    r99404 r105670  
    251251
    252252  @param[in]  This                         Indicates a pointer to the calling context.
    253   @param[in]  MediaId                      ID of the medium to receive data from.
     253  @param[in]  MediaId                      ID of the medium to receive data from. If there is no
     254                                           block IO protocol supported by the physical device, the
     255                                           value of MediaId is undefined.
    254256  @param[in]  Timeout                      The timeout, in 100ns units, to use for the execution
    255257                                           of the security protocol command. A Timeout value of 0
     
    338340
    339341  @param  This                         Indicates a pointer to the calling context.
    340   @param  MediaId                      ID of the medium to receive data from.
     342  @param  MediaId                      ID of the medium to receive data from. If there is no
     343                                       block IO protocol supported by the physical device, the
     344                                       value of MediaId is undefined.
    341345  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    342346                                       of the security protocol command. A Timeout value of 0
     
    418422
    419423  @param  This                         Indicates a pointer to the calling context.
    420   @param  MediaId                      ID of the medium to receive data from.
     424  @param  MediaId                      ID of the medium to receive data from. If there is no
     425                                       block IO protocol supported by the physical device, the
     426                                       value of MediaId is undefined.
    421427  @param  Timeout                      The timeout, in 100ns units, to use for the execution
    422428                                       of the security protocol command. A Timeout value of 0
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.c

    r99404 r105670  
    693693  @retval EFI_DEVICE_ERROR     The keystroke information was not returned due to
    694694                               hardware errors.
     695  @retval EFI_UNSUPPORTED      The device does not support the ability to read keystroke data.
    695696
    696697**/
     
    976977                                 hardware errors.
    977978  @retval EFI_INVALID_PARAMETER  KeyData is NULL.
     979  @retval EFI_UNSUPPORTED        The device does not support the ability to read keystroke data.
    978980
    979981**/
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Usb/UsbKbDxe/EfiKey.h

    r99404 r105670  
    413413  @retval EFI_DEVICE_ERROR     The keystroke information was not returned due to
    414414                               hardware errors.
     415  @retval EFI_UNSUPPORTED      The device does not support the ability to read keystroke data.
    415416
    416417**/
     
    467468                                 hardware errors.
    468469  @retval EFI_INVALID_PARAMETER  KeyData is NULL.
     470  @retval EFI_UNSUPPORTED        The device does not support the ability to read keystroke data.
    469471
    470472**/
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Usb/UsbNetwork/NetworkCommon/PxeFunction.c

    r101291 r105670  
    830830
    831831    Nic->UsbEth->UsbEthFunDescriptor (Nic->UsbEth, &UsbEthFunDescriptor);
    832     if ((UsbEthFunDescriptor.NumberMcFilters << 1) == 0) {
     832    if ((UsbEthFunDescriptor.NumberMcFilters & MAC_FILTERS_MASK) == 0) {
    833833      Nic->RxFilter |= PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST;
    834834      Nic->UsbEth->SetUsbEthPacketFilter (Nic->UsbEth, Nic->RxFilter);
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcEcm/UsbEcmFunction.c

    r101291 r105670  
    629629  }
    630630
    631   if ((UsbEthFunDescriptor.NumberMcFilters << 1) == 0) {
     631  if ((UsbEthFunDescriptor.NumberMcFilters & MAC_FILTERS_MASK) == 0) {
    632632    return EFI_UNSUPPORTED;
    633633  }
     
    770770  Count = sizeof (gTable)/sizeof (gTable[0]);
    771771
    772   for (Index = 0; (gTable[Index].Src != 0) && (Index < Count); Index++) {
     772  for (Index = 0; (Index < Count) && (gTable[Index].Src != 0); Index++) {
    773773    if (gTable[Index].Src & Value) {
    774774      *CdcFilter |= gTable[Index].Dst;
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Usb/UsbNetwork/UsbCdcNcm/UsbNcmFunction.c

    r101291 r105670  
    715715  }
    716716
    717   if ((UsbEthFunDescriptor.NumberMcFilters << 1) == 0) {
     717  if ((UsbEthFunDescriptor.NumberMcFilters & MAC_FILTERS_MASK) == 0) {
    718718    return EFI_UNSUPPORTED;
    719719  }
     
    856856  Count = sizeof (gTable)/sizeof (gTable[0]);
    857857
    858   for (Index = 0; (gTable[Index].Src != 0) && (Index < Count); Index++) {
     858  for (Index = 0; (Index < Count) && (gTable[Index].Src != 0); Index++) {
    859859    if (gTable[Index].Src & Value) {
    860860      *CdcFilter |= gTable[Index].Dst;
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndis.c

    r101291 r105670  
    4141
    4242  // Check specific device/RNDIS and CDC-DATA
    43   if (((InterfaceDescriptor.InterfaceClass == 0x2) &&
    44        (InterfaceDescriptor.InterfaceSubClass == 0x2) &&
    45        (InterfaceDescriptor.InterfaceProtocol == 0xFF)) || \
    46       ((InterfaceDescriptor.InterfaceClass == 0xEF) &&
    47        (InterfaceDescriptor.InterfaceSubClass == 0x4) &&
    48        (InterfaceDescriptor.InterfaceProtocol == 0x1)) || \
    49       ((InterfaceDescriptor.InterfaceClass == 0xA) &&
    50        (InterfaceDescriptor.InterfaceSubClass == 0x0) &&
    51        (InterfaceDescriptor.InterfaceProtocol == 0x00))
     43  if (((InterfaceDescriptor.InterfaceClass == USB_CDC_CLASS) &&
     44       (InterfaceDescriptor.InterfaceSubClass == USB_CDC_ACM_SUBCLASS) &&
     45       (InterfaceDescriptor.InterfaceProtocol == USB_VENDOR_PROTOCOL)) || \
     46      ((InterfaceDescriptor.InterfaceClass == USB_MISC_CLASS) &&
     47       (InterfaceDescriptor.InterfaceSubClass == USB_RNDIS_SUBCLASS) &&
     48       (InterfaceDescriptor.InterfaceProtocol == USB_RNDIS_ETHERNET_PROTOCOL)) || \
     49      ((InterfaceDescriptor.InterfaceClass == USB_CDC_DATA_CLASS) &&
     50       (InterfaceDescriptor.InterfaceSubClass == USB_CDC_DATA_SUBCLASS) &&
     51       (InterfaceDescriptor.InterfaceProtocol == USB_NO_CLASS_PROTOCOL))
    5252      )
    5353  {
     
    8080
    8181  // Check for specific device/RNDIS and CDC-DATA
    82   if (((InterfaceDescriptor.InterfaceClass == 0x2) &&
    83        (InterfaceDescriptor.InterfaceSubClass == 0x2) &&
    84        (InterfaceDescriptor.InterfaceProtocol == 0xFF)) || \
    85       ((InterfaceDescriptor.InterfaceClass == 0xEF) &&
    86        (InterfaceDescriptor.InterfaceSubClass == 0x4) &&
    87        (InterfaceDescriptor.InterfaceProtocol == 0x1))
     82  if (((InterfaceDescriptor.InterfaceClass == USB_CDC_CLASS) &&
     83       (InterfaceDescriptor.InterfaceSubClass == USB_CDC_ACM_SUBCLASS) &&
     84       (InterfaceDescriptor.InterfaceProtocol == USB_VENDOR_PROTOCOL)) || \
     85      ((InterfaceDescriptor.InterfaceClass == USB_MISC_CLASS) &&
     86       (InterfaceDescriptor.InterfaceSubClass == USB_RNDIS_SUBCLASS) &&
     87       (InterfaceDescriptor.InterfaceProtocol == USB_RNDIS_ETHERNET_PROTOCOL))
    8888      )
    8989  {
     
    156156
    157157  // Check for CDC-DATA
    158   if ((InterfaceDescriptor.InterfaceClass == 0xA) &&
    159       (InterfaceDescriptor.InterfaceSubClass == 0x0) &&
    160       (InterfaceDescriptor.InterfaceProtocol == 0x0))
     158  if ((InterfaceDescriptor.InterfaceClass == USB_CDC_DATA_CLASS) &&
     159      (InterfaceDescriptor.InterfaceSubClass == USB_CDC_DATA_SUBCLASS) &&
     160      (InterfaceDescriptor.InterfaceProtocol == USB_NO_CLASS_PROTOCOL))
    161161  {
    162162    return TRUE;
     
    189189
    190190  // Check for Rndis
    191   if ((InterfaceDescriptor.InterfaceClass == 0x2) &&
    192       (InterfaceDescriptor.InterfaceSubClass == 0x2) &&
    193       (InterfaceDescriptor.InterfaceProtocol == 0xFF))
     191  if ((InterfaceDescriptor.InterfaceClass == USB_CDC_CLASS) &&
     192      (InterfaceDescriptor.InterfaceSubClass == USB_CDC_ACM_SUBCLASS) &&
     193      (InterfaceDescriptor.InterfaceProtocol == USB_VENDOR_PROTOCOL))
    194194  {
    195195    return TRUE;
  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis/UsbRndisFunction.c

    r101291 r105670  
    662662  }
    663663
    664   if ((UsbEthFunDescriptor.NumberMcFilters << 1) == 0) {
     664  if ((UsbEthFunDescriptor.NumberMcFilters & MAC_FILTERS_MASK) == 0) {
    665665    return EFI_UNSUPPORTED;
    666666  }
     
    804804  Count = sizeof (gTable)/sizeof (gTable[0]);
    805805
    806   for (Index = 0; (gTable[Index].Src != 0) && (Index < Count); Index++) {
     806  for (Index = 0; (Index < Count) && (gTable[Index].Src != 0); Index++) {
    807807    if (gTable[Index].Src & Value) {
    808808      *CdcFilter |= gTable[Index].Dst;
     
    857857
    858858    Nic->UsbEth->UsbEthFunDescriptor (Nic->UsbEth, &UsbEthFunDescriptor);
    859     if ((UsbEthFunDescriptor.NumberMcFilters << 1) == 0) {
     859    if ((UsbEthFunDescriptor.NumberMcFilters & MAC_FILTERS_MASK) == 0) {
    860860      Nic->RxFilter |= PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST;
    861861      DEBUG ((DEBUG_INFO, "SetUsbEthPacketFilter Nic %lx Nic->UsbEth %lx ", Nic, Nic->UsbEth));
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette