Download UEFI Driver Writer`s Guide
Transcript
•
Call Flush().
•
Call Unmap().
•
The processor may read the contents of the DMA buffer using HostAddress.
The following example shows a function to perform a bus master write operation on a
PCI controller. The PCI controller is accessed through the parameter PciIo. The system
memory buffer written by the bus master is specified by HostAddress and Length. This
function performs one or more bus master write operations until either Length bytes
have been written by the bus master or an error is detected.
The PCI controller in this example has three MMIO registers in BAR #1. The MMIO
register at offset 0x10 is a status register the function uses to check whether the DMA
operation is complete or not. The function writes the start of the DMA transaction to
the MMIO register at offset 0x20 and the length of the DMA transaction to the MMIO
register at offset 0x24. The write operation to offset 0x24 also starts the DMA write
operation. The services of the PCI I/O Protocol used in this example include Map(),
Unmap(), Mem.Write(), PollMem(), and Flush().
A 32-bit PCI bus master is used for this example. A 64-bit PCI bus master would
involve two 32-bit MMIO registers to specify the start address and two 32-bit MMIO
registers to specify the length. If the PCI bus master supports 64-bit DMA addressing,
the EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE attribute must be set in the Driver Binding
Protocol Start() service of the PCI driver.
#include <Uefi.h>
#include <Protocol/PciIo.h>
#include <Library/UefiLib.h>
EFI_STATUS
EFIAPI
DoBusMasterWrite (
IN EFI_PCI_IO_PROTOCOL *PciIo,
IN UINT8
*HostAddress,
IN UINTN
*Length
)
{
EFI_STATUS
Status;
UINTN
NumberOfBytes;
EFI_PHYSICAL_ADDRESS DeviceAddress;
VOID
*Mapping;
UINT32
DmaStartAddress;
UINT64
ControllerStatus;
//
// Loop until the entire buffer specified by HostAddress and
// Length has been written by the PCI DMA bus master
//
do {
//
// Call Map() to retrieve the DeviceAddress to use for the bus
// master write operation. The Map() function may not support
// performing a DMA operation for the entire length, so it may
// be broken up into smaller DMA operations.
//
NumberOfBytes = *Length;
Status = PciIo->Map (
PciIo,
// This
EfiPciIoOperationBusMasterWrite, // Operation
(VOID *)HostAddress,
// HostAddress
&NumberOfBytes,
// NumberOfBytes
360
3/8/2012
Version 1.01
Related documents
Crate CSM16 Specifications
Linksys WIP310 IP Phone User Manual
HP RX2600 User's Manual
Nautilus EV916 User's Manual
EFI Shell User`s Guide Draft for Review
Diagnostics, Pages 201-264 - Suncoast Surgical & Medical Supply
INTELLIGENT SPEED DOME USER`S MANUAL
EDK II DSC File Specification
EDKII User Manual V0.60
Intel® Boot Loader Development Kit V2.0
MTD 216-100A Specifications
Intel Boot Loader Development Kit (Intel BLDK)