Re: [edk2] Help debugging PEIM on Minnowboard Max
Hi, Eric >From XHCI spec view, there is no data buffer alignment requirement for control >transfer (you can refer to XHCI1.0 section 6.4.1.2.2 Table 72). So I don't know why you found 16 byte alignment issue for reading usb device/config descriptor. Did you ensure the device descriptor you get is correct? I also have no idea on the issue of reading 272 bytes config descriptor. You may have to dig into it by debugger. Per my experience, some xHCI related initialization jobs are done in PEI/DXE phase chipset init driver, you may need copy them to your PEI driver before using xHCI to do transaction. Thanks Feng -Original Message- From: Eric Wittmayer [mailto:e...@frescologic.com] Sent: Tuesday, September 08, 2015 14:38 To: Tian, Feng; edk2-devel@lists.01.org Subject: RE: [edk2] Help debugging PEIM on Minnowboard Max Thanks to Feng pointing me in the right direction, I've got this starting to work but I have encountered some strangeness. I wrote the PEIM below to configure the xHCI controller and install the PEI_USB_CONTROLLER_PPI. I was seeing some problems reading device and config descriptors and found that if the memory locations I was reading descriptors into aren't at least 16 byte aligned, I wasn't getting all the data in memory. I know PCIe accesses are dword aligned and use byte enables for the first/last dword to handle byte alignment but I don't understand why it would be sensitive to alignment larger than dwords. I'm currently stuck trying to read a 272 byte config descriptor. I'm reading it into a page aligned chunk of memory but I'm still getting an exception in the debugger when I execute the request on the xHCI host. What I see in the xHCI event ring after the doorbell ring are event TRBs for the setup and data stages of the control transfer but no event for the status stage. After that things seem wedged. My USB analyzer shows the Setup and data stages happening over USB but the host doesn't initiate the Status stage. I'm using PeiServicesAllocatePages to allocate memory to read the descriptor into. Do I need to use a specific type of memory to allow DMA transfers from the xHCI host to function properly? Thanks for any ideas, Eric Here is the Xhci initialization code, the Base address I'm using is the same as the system uses in the Dxe phase per Feng's suggestion. Index: Vlv2TbltDevicePkg/XhciPpi/XhciPpi.inf === --- Vlv2TbltDevicePkg/XhciPpi/XhciPpi.inf (revision 0) +++ Vlv2TbltDevicePkg/XhciPpi/XhciPpi.inf (revision 29801) @@ -0,0 +1,49 @@ +# Copyright (c) 2015, Fresco Logic, Inc. All rights reserved. + +# This program and the accompanying materials are licensed and made available under +# the terms and conditions of the BSD License that accompanies this distribution. +# The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. + +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" +BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +# Module Name: + +# XhciPpi.h + +# Abstract: + +# For Minnowboard Max set the xHCI controller memory BAR address and # +configure the usb ports to connect to the xhci controller instead # of +the EHCI controller. +# Implement and install the PEI_USB_CONTROLLER_PPI during the Pei +phase # for use in recovery. + +[defines] + INF_VERSION= 0x00010005 + BASE_NAME = XhciPpi + FILE_GUID = 340188CF-27A4-417E-8285-758AFF34F91C + MODULE_TYPE= PEIM + VERSION_STRING = 1.0 + PI_SPECIFICATION_VERSION = 0x0001000A + ENTRY_POINT= XhciPpiEntry + +[sources.common] + XhciPpi.c + XhciPpi.h + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + +[LibraryClasses] + PeimEntryPoint + DebugLib + PciLib + +[Ppis] + gPeiUsbControllerPpiGuid ## PRODUCES + +[Depex] + TRUE Index: Vlv2TbltDevicePkg/XhciPpi/XhciPpi.c === --- Vlv2TbltDevicePkg/XhciPpi/XhciPpi.c (revision 0) +++ Vlv2TbltDevicePkg/XhciPpi/XhciPpi.c (revision 29801) @@ -0,0 +1,149 @@ +/*++ + +Copyright (c) 2015, Fresco Logic, Inc. All rights reserved. + +This program and the accompanying materials are licensed and made +available under +the terms and conditions of the BSD License that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + XhciPpi.c + +Abstract: + +For Minnowboard Max set the xHCI controller memory BAR address and +configure the usb ports to connect to the xhci controller instea
Re: [edk2] Help debugging PEIM on Minnowboard Max
EDKII mass storage PEIM drivers were developed for recovery mode, that's why you can see a gEfiPeiBootInRecoveryModePpiGuid dependency in their INF files. So they don't meet your usage model and you need make some code changes and introduce a usb host controller PEIM driver like I said before. As for the BAR, a simple way is booting to shell and see which bar is used in DXE phase and then hardcode it in your usb host controller PEIM driver. Last, as far as I know there is no reference platform enabling pure xhci pei support. -Original Message- From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Eric Wittmayer Sent: Tuesday, August 18, 2015 13:00 To: Tian, Feng; edk2-devel@lists.01.org Subject: Re: [edk2] Help debugging PEIM on Minnowboard Max Hi Feng, Now I understand the concept. I was expecting that PEIM would already be available for the Minnowboard Max. Is Usb in the PEI phase not supported in Minnowboard? From my digging in the code today, it seems to enable the xhci controller, it's PCI BAR needs to be set and enabled for memory access. I found memory base addresses for some devices in Vlv2DeviceRefCodePkg\ValleyView2Soc\NorthCluster\Include\PlatformBaseAddress es.h but not for XHCI. From looking at the Atom E3800 datasheet, the xhci memory base doesn't have a fixed location so I believe I need to pick an unused range in the Low MMIO space to set as the xhci BAR. If you or someone else on the list can recommend a different platform that already supports xhci in the PEI phase to use as a development platform that might be a better option for me. Thank you again for your patience and prompt responses. Eric -Original Message- From: Tian, Feng [mailto:feng.t...@intel.com] Sent: Sunday, August 16, 2015 10:20 PM To: Eric Wittmayer; edk2-devel@lists.01.org Cc: Tian, Feng Subject: RE: [edk2] Help debugging PEIM on Minnowboard Max Do you look into the UsbController.h in MdeModulePkg/Include/Ppi directory? typedef EFI_STATUS (EFIAPI *PEI_GET_USB_CONTROLLER)( IN EFI_PEI_SERVICES**PeiServices, IN PEI_USB_CONTROLLER_PPI *This, IN UINT8 UsbControllerId, OUT UINTN *ControllerType, OUT UINTN *BaseAddress ); You need write a PEIM to produce this PPI and implement the above interface according to your platform setting. For how to write a PEIM module, you can refer to EDKII Module Writer's Guide in edk2.sourceforge.net Thanks Feng -Original Message- From: Eric Wittmayer [mailto:e...@frescologic.com] Sent: Monday, August 17, 2015 11:50 To: Tian, Feng; edk2-devel@lists.01.org Subject: RE: [edk2] Help debugging PEIM on Minnowboard Max Hi Feng, I see now that XhciPei needs gPeiUsbControllerPpiGuid and creates gPeiUsbHostControllerPpiGuid which UsbBusPei needs. I can't seem to figure out what creates gPeiUsbControllerPpiGuid? I see it listed in the .dec file I'm using but that apparently isn't enough to install the Ppi. What should be installing the gPeiUsbControllerPpiGuid? Thanks, Eric -Original Message- From: Tian, Feng [mailto:feng.t...@intel.com] Sent: Sunday, August 16, 2015 6:09 PM To: Eric Wittmayer; edk2-devel@lists.01.org Cc: Tian, Feng Subject: RE: [edk2] Help debugging PEIM on Minnowboard Max Eric, I must agree the naming of these usb pei related ppi guids are not good, which misleads you. There is no the chicken and egg problem. gPeiUsbHostControllerPpiGuid and gPeiUsbControllerPpiGuid are two different ppis. The former is consumed by UsbPei and the latter is consumed by XhciPei. You need write a pei module to produce PeiUsbControllerPpi (see MdeModulePkg/Include/Ppi for definitions) at first. Thanks Feng -Original Message- From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Eric Wittmayer Sent: Saturday, August 15, 2015 08:12 To: edk2-devel@lists.01.org Subject: [edk2] Help debugging PEIM on Minnowboard Max I'm writing a PEIM for a USB3 device but having trouble even getting the UsbBusPie and XhciPei modules to load during boot. I thought getting the existing Usb Peims to load would be a good first step. I looked at the DEPEX for both of the above modules and tried removing gEfiPeiBootInRecoveryModePpiGuid but I didn't see them load. If I set both of their DEPEX == TRUE then I see some print statements that show they are at least trying to load but then I have a chicken and egg problem in that UsbBusPie needs either gPeiUsbHostControllerPpiGuid or gPeiUsb2HostControllerPpiGuid which come from XhciPei. However, XhciPei needs gPeiUsbControllerPpiGuid which comes from UsbBusPei before it will install the gPeiUsb2HostControllerPpiGuid. The same cross dependency is shown in the DEPEX for these two modules. I feel like I'm missing something simple
Re: [edk2] Help debugging PEIM on Minnowboard Max
Hi Feng, Now I understand the concept. I was expecting that PEIM would already be available for the Minnowboard Max. Is Usb in the PEI phase not supported in Minnowboard? From my digging in the code today, it seems to enable the xhci controller, it's PCI BAR needs to be set and enabled for memory access. I found memory base addresses for some devices in Vlv2DeviceRefCodePkg\ValleyView2Soc\NorthCluster\Include\PlatformBaseAddress es.h but not for XHCI. From looking at the Atom E3800 datasheet, the xhci memory base doesn't have a fixed location so I believe I need to pick an unused range in the Low MMIO space to set as the xhci BAR. If you or someone else on the list can recommend a different platform that already supports xhci in the PEI phase to use as a development platform that might be a better option for me. Thank you again for your patience and prompt responses. Eric -Original Message- From: Tian, Feng [mailto:feng.t...@intel.com] Sent: Sunday, August 16, 2015 10:20 PM To: Eric Wittmayer; edk2-devel@lists.01.org Cc: Tian, Feng Subject: RE: [edk2] Help debugging PEIM on Minnowboard Max Do you look into the UsbController.h in MdeModulePkg/Include/Ppi directory? typedef EFI_STATUS (EFIAPI *PEI_GET_USB_CONTROLLER)( IN EFI_PEI_SERVICES**PeiServices, IN PEI_USB_CONTROLLER_PPI *This, IN UINT8 UsbControllerId, OUT UINTN *ControllerType, OUT UINTN *BaseAddress ); You need write a PEIM to produce this PPI and implement the above interface according to your platform setting. For how to write a PEIM module, you can refer to EDKII Module Writer's Guide in edk2.sourceforge.net Thanks Feng -Original Message- From: Eric Wittmayer [mailto:e...@frescologic.com] Sent: Monday, August 17, 2015 11:50 To: Tian, Feng; edk2-devel@lists.01.org Subject: RE: [edk2] Help debugging PEIM on Minnowboard Max Hi Feng, I see now that XhciPei needs gPeiUsbControllerPpiGuid and creates gPeiUsbHostControllerPpiGuid which UsbBusPei needs. I can't seem to figure out what creates gPeiUsbControllerPpiGuid? I see it listed in the .dec file I'm using but that apparently isn't enough to install the Ppi. What should be installing the gPeiUsbControllerPpiGuid? Thanks, Eric -Original Message- From: Tian, Feng [mailto:feng.t...@intel.com] Sent: Sunday, August 16, 2015 6:09 PM To: Eric Wittmayer; edk2-devel@lists.01.org Cc: Tian, Feng Subject: RE: [edk2] Help debugging PEIM on Minnowboard Max Eric, I must agree the naming of these usb pei related ppi guids are not good, which misleads you. There is no the chicken and egg problem. gPeiUsbHostControllerPpiGuid and gPeiUsbControllerPpiGuid are two different ppis. The former is consumed by UsbPei and the latter is consumed by XhciPei. You need write a pei module to produce PeiUsbControllerPpi (see MdeModulePkg/Include/Ppi for definitions) at first. Thanks Feng -Original Message- From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Eric Wittmayer Sent: Saturday, August 15, 2015 08:12 To: edk2-devel@lists.01.org Subject: [edk2] Help debugging PEIM on Minnowboard Max I'm writing a PEIM for a USB3 device but having trouble even getting the UsbBusPie and XhciPei modules to load during boot. I thought getting the existing Usb Peims to load would be a good first step. I looked at the DEPEX for both of the above modules and tried removing gEfiPeiBootInRecoveryModePpiGuid but I didn't see them load. If I set both of their DEPEX == TRUE then I see some print statements that show they are at least trying to load but then I have a chicken and egg problem in that UsbBusPie needs either gPeiUsbHostControllerPpiGuid or gPeiUsb2HostControllerPpiGuid which come from XhciPei. However, XhciPei needs gPeiUsbControllerPpiGuid which comes from UsbBusPei before it will install the gPeiUsb2HostControllerPpiGuid. The same cross dependency is shown in the DEPEX for these two modules. I feel like I'm missing something simple and fundamental and I'm hoping someone will point me in the right direction. Thanks, Eric W ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] Help debugging PEIM on Minnowboard Max
Eric, I must agree the naming of these usb pei related ppi guids are not good, which misleads you. There is no the chicken and egg problem. gPeiUsbHostControllerPpiGuid and gPeiUsbControllerPpiGuid are two different ppis. The former is consumed by UsbPei and the latter is consumed by XhciPei. You need write a pei module to produce PeiUsbControllerPpi (see MdeModulePkg/Include/Ppi for definitions) at first. Thanks Feng -Original Message- From: edk2-devel [mailto:edk2-devel-boun...@lists.01.org] On Behalf Of Eric Wittmayer Sent: Saturday, August 15, 2015 08:12 To: edk2-devel@lists.01.org Subject: [edk2] Help debugging PEIM on Minnowboard Max I'm writing a PEIM for a USB3 device but having trouble even getting the UsbBusPie and XhciPei modules to load during boot. I thought getting the existing Usb Peims to load would be a good first step. I looked at the DEPEX for both of the above modules and tried removing gEfiPeiBootInRecoveryModePpiGuid but I didn't see them load. If I set both of their DEPEX == TRUE then I see some print statements that show they are at least trying to load but then I have a chicken and egg problem in that UsbBusPie needs either gPeiUsbHostControllerPpiGuid or gPeiUsb2HostControllerPpiGuid which come from XhciPei. However, XhciPei needs gPeiUsbControllerPpiGuid which comes from UsbBusPei before it will install the gPeiUsb2HostControllerPpiGuid. The same cross dependency is shown in the DEPEX for these two modules. I feel like I'm missing something simple and fundamental and I'm hoping someone will point me in the right direction. Thanks, Eric W ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] Help debugging PEIM on Minnowboard Max
I'm writing a PEIM for a USB3 device but having trouble even getting the UsbBusPie and XhciPei modules to load during boot. I thought getting the existing Usb Peims to load would be a good first step. I looked at the DEPEX for both of the above modules and tried removing gEfiPeiBootInRecoveryModePpiGuid but I didn't see them load. If I set both of their DEPEX == TRUE then I see some print statements that show they are at least trying to load but then I have a chicken and egg problem in that UsbBusPie needs either gPeiUsbHostControllerPpiGuid or gPeiUsb2HostControllerPpiGuid which come from XhciPei. However, XhciPei needs gPeiUsbControllerPpiGuid which comes from UsbBusPei before it will install the gPeiUsb2HostControllerPpiGuid. The same cross dependency is shown in the DEPEX for these two modules. I feel like I'm missing something simple and fundamental and I'm hoping someone will point me in the right direction. Thanks, Eric W ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel