18.6.2 PCI I/O FIFO operations

The examples below show an example of writing a sector to an IDE controller. The IDE controller uses a single 16-bit I/O port as a FIFO for reading and writing sector data. The first example calls the PCI I/O Protocol 256 times to write the sector. The second example calls the PCI I/O Protocol once to perform the same operation, providing better performance if compiled with an EBC compiler. This example applies equally to FIFO read operations.

Example 186-PCI I/O FIFO using a loop

#include <Uefi.h>
#include <Protocol/PciIo.h>
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
UINTN Index;
UINT16 Buffer[256];
//
// This is the slowest method. It performs 256 PCI I/O calls to write 256
// 16-bit values to the IDE controller.
//
for (Index = 0; Index < 256; Index++) {
Status = PciIo->Io.Write (
PciIo, // This
EfiPciIoWidthUint16, // Width
EFI_PCI_IO_PASS_THROUGH_BAR, // BarIndex
0x1F0, // Offset
1, // Count
&Buffer[Index] // Buffer
);
}

Example 187-PCI I/O FIFO without a loop

#include <Uefi.h>
#include <Protocol/PciIo.h>
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
UINT16 Buffer[256];
//
// This is the fastest method. It uses a loop to write 256 16-bit values to
// the IDE controller.
//
Status = PciIo->Io.Write (
PciIo, // This
EfiPciIoWidthFifoUint16, // Width
EFI_PCI_IO_PASS_THROUGH_BAR, // BarIndex
0x1F0, // Offset
256, // Count
Buffer // Buffer
);