porting a pci driver to arm aarch64 platforms · presented by porting a pci driver to arm aarch64...
TRANSCRIPT
![Page 1: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/1.jpg)
presented by
Porting a PCI driver to ARM AArch64 platforms
UEFI Spring Plugfest – May 18-22, 2015Presented by Olivier MARTIN (ARM Ltd)
UEFI Plugfest – May 2015 www.uefi.org 1
Updated 2011-06-01
![Page 2: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/2.jpg)
Agenda
• Context
• About PCI
• Recommendations &Good Practices
• About EFI Byte Code (EBC)
• At this event
UEFI Plugfest – May 2015 www.uefi.org 2
![Page 3: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/3.jpg)
Context
UEFI Plugfest – May 2015 www.uefi.org 3
![Page 4: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/4.jpg)
ARM platforms until recently
• Mainly mobile consumer oriented or embedded platforms
… no strong push for PCI support
UEFI Plugfest – May 2015 www.uefi.org 4
![Page 5: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/5.jpg)
ARM platforms until recently
• Most platforms had Ethernet & USB supports… and sometimes SATA
… and even some confidential PCI support
… but always memory mapped devices
UEFI Plugfest – May 2015 www.uefi.org 5
Freescale i.MX6
Marvell Sheevaplug
Development Kit
![Page 6: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/6.jpg)
New Opportunities & Markets
• Parity with other architectures / platforms
• Need to address Server market requirements
UEFI Plugfest – May 2015 www.uefi.org 6
![Page 7: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/7.jpg)
Latest ARM platforms
UEFI Plugfest – May 2015 www.uefi.org 7
Applied Micro
X-C1™
ARM Juno
Cavium
ThunderX™
AMD “Seattle”
HiSilicon D02
![Page 8: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/8.jpg)
About PCI
UEFI Plugfest – May 2015 www.uefi.org 8
![Page 9: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/9.jpg)
PCI in the context of UEFI
• PCI Devices might be enumerated at boot time
• UEFI driver in PCI Option ROM
• ACPI ‘MCFG’ Table exposed by UEFI firmware
• … Need for OS Generic PCI Root Bridge driver
UEFI Plugfest – May 2015 www.uefi.org 9
![Page 10: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/10.jpg)
PCI in the context of ARM
• It should not be different compared to other architectures
UEFI Plugfest – May 2015 www.uefi.org 10
![Page 11: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/11.jpg)
PCI in the context of ARM
• It should not be different compared to other architectures … in theory
UEFI Plugfest – May 2015 www.uefi.org 11
![Page 12: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/12.jpg)
PCI in the context of ARM
• It should not be different compared to other architectures … in theory*
* - MSI only supported from ARM GICv2m specification
- PCI Bus not necessarily coherent with the CPU
- No PCI IO space support- Likely to be ECAM only
UEFI Plugfest – May 2015 www.uefi.org 12
![Page 13: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/13.jpg)
Recommendations &Good practices
UEFI Plugfest – May 2015 www.uefi.org 13
![Page 14: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/14.jpg)
Recommendation 1
• Do not use direct memory access / MmioLib
Some PCI Root Complex require translation logic to convert from PCI to AXI buses
Avoid architecture / platform specificities
UEFI Plugfest – May 2015 www.uefi.org 14
![Page 15: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/15.jpg)
Recommendation 1 (cont…)
In practice, move from:Value32 = MmioRead32 (Port->RegBase +
SII3132_PORT_SSTATUS_REG);
*(UINT32)(SataPort->RegBase + SII3132_PORT_INTSTATUS_REG)=
IrqMask;
to:Status = PciIo->Mem.Read (PciIo, EfiPciWidthUint32,
Port->RegBase + SII3132_PORT_SSTATUS_REG, 1, &Value32);
Status = PciIo->Mem.Write (PciIo, EfiPciWidthUint32,
SataPort->RegBase + SII3132_PORT_INTSTATUS_REG, 1,
IrqMask);
UEFI Plugfest – May 2015 www.uefi.org 15
![Page 16: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/16.jpg)
Recommendation 1 (cont…)
In practice, move from:CopyMem ((VOID*)(SataPort->RegBase + (EmptySlot * 0x80)),
SataPort->HostPRB, sizeof (SATA_SI3132_PRB));
to:PciIo->Mem.Write (PciIo, EfiPciIoWidthUint8, 1, // Bar 1
SataPort->RegBase + (EmptySlot * 0x80),
sizeof (SATA_SI3132_PRB), SataPort->HostPRB);
UEFI Plugfest – May 2015 www.uefi.org 16
![Page 17: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/17.jpg)
Recommendation 1 (cont…)
In practice, move from:CopyMem ((VOID*)(SataPort->RegBase + (EmptySlot * 0x80)),
SataPort->HostPRB, sizeof (SATA_SI3132_PRB));
to:PciIo->Mem.Write (PciIo, EfiPciIoWidthUint8, 1, // Bar 1
SataPort->RegBase + (EmptySlot * 0x80),
sizeof (SATA_SI3132_PRB), SataPort->HostPRB);
or even better:
PciIo->Mem.Write (PciIo, EfiPciIoWidthUint32, 1, // Bar 1SataPort->RegBase + (EmptySlot * 0x80),
sizeof (SATA_SI3132_PRB) / 4, SataPort->HostPRB);
UEFI Plugfest – May 2015 www.uefi.org 17
![Page 18: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/18.jpg)
Recommendation 2
• Do not use TimerLib!
Since ARMv8, ARM introduced a Generic Timer (similarly from ARMv7 there has been the ‘Generic Timer Extension’).
But the UEFI specification already offers API for this purpose - see BootServices.Stall()
UEFI Plugfest – May 2015 www.uefi.org 18
![Page 19: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/19.jpg)
Good practice 1
• Be aware you might have multiple instances of the same PCI card plugged in your platform!
Consider carefully global variables!
EFI_PCI_IO_PROTOCOL* gPciIo; // No!!!!
UEFI Plugfest – May 2015 www.uefi.org 19
![Page 20: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/20.jpg)
Good practice 2
• Build your PCI driver with:
different toolchains (MS Visual Studio, GCC, LLVM, etc)
different architectures (32-bit, 64-bit, ARM, Intel, etc)
UEFI Plugfest – May 2015 www.uefi.org 20
![Page 21: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/21.jpg)
Good practice 3
• Use UEFI protocols / Boot Services in preference to EDK(2) Libraries
Code smaller, driver more portable
Rely on the platform UEFI firmware But that’s why we have UEFI conformance
tests!
UEFI Plugfest – May 2015 www.uefi.org 21
![Page 22: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/22.jpg)
Note
• All these recommendations are not specific to ARM architectures and PCI UEFI drivers!
UEFI Plugfest – May 2015 www.uefi.org 22
![Page 23: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/23.jpg)
In practice…
• Ensure your PCI driver lives into an architecture independent EDK(2) package
• Review the library dependencies in your driver INF file.
• Build your driver with at least two toolchainsand architectures and DEBUG/RELEASE
UEFI Plugfest – May 2015 www.uefi.org 23
![Page 24: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/24.jpg)
About EFI Byte Code (EBC)
UEFI Plugfest – May 2015 www.uefi.org 24
![Page 25: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/25.jpg)
What is / Why EBC?
UEFI Plugfest – May 2015 www.uefi.org 25
![Page 26: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/26.jpg)
The questions of EBC support
• Should EBC work on ARM? Yes
UEFI Plugfest – May 2015 www.uefi.org 26
![Page 27: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/27.jpg)
The questions of EBC support
• Should EBC work on ARM? Yes, but it is not implemented at the moment
UEFI Plugfest – May 2015 www.uefi.org 27
![Page 28: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/28.jpg)
The questions of EBC support
• Should EBC work on ARM? Yes, but it is not implemented at the moment
• What do I need to build an EBC PCI driver? A $995 compiler…
UEFI Plugfest – May 2015 www.uefi.org 28
![Page 29: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/29.jpg)
The questions of EBC support
• Should EBC work on ARM? Yes, but it is not implemented at the moment
• What do I need to build an EBC PCI driver? A $995 compiler…
• Should your driver support EBC? Some people say yes, and other say no…
UEFI Plugfest – May 2015 www.uefi.org 29
![Page 30: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/30.jpg)
At this event
UEFI Plugfest – May 2015 www.uefi.org 30
![Page 31: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/31.jpg)
Take advantage of this event
• There will be ARM platforms with PCI support (likely to be AArch64 platforms)
• ARM Engineers with platforms and debug tools to help you to test your PCI driversand support you
UEFI Plugfest – May 2015 www.uefi.org 31
![Page 32: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/32.jpg)
First step to support ARM…
• Build your driver (for free)
UEFI Plugfest – May 2015 www.uefi.org 32
![Page 33: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/33.jpg)
Going further…
UEFI Plugfest – May 2015 www.uefi.org 33
ARM Juno Development Platform ARM DS-5 Development Studio
ARM DSTREAM High Performance Debug & Trace
![Page 34: Porting a PCI driver to ARM AArch64 platforms · presented by Porting a PCI driver to ARM AArch64 platforms UEFI Spring Plugfest –May 18-22, 2015 Presented by Olivier MARTIN (ARM](https://reader030.vdocuments.net/reader030/viewer/2022021805/5ba9a2ac09d3f2155e8d1799/html5/thumbnails/34.jpg)
Thanks for attending the UEFI Spring Plugfest 2015
For more information on the Unified EFI Forum and UEFI Specifications, visit http://www.uefi.org
presented by
UEFI Plugfest – May 2015 www.uefi.org 34