Device I/O Protocol
Version 1.02 12/12/00 139
Description
The DEVICE_IO protocol provides the basic Memory, I/O, and PCI interfaces that are used to
abstract accesses to devices.
A driver that controls a physical device obtains the proper DEVICE_IO protocol interface by
checking for the supported protocol on the programmatic parent(s) for the device. This is easily
done via the LocateDevicePath() function.
The following C code fragment illustrates the use of the DEVICE_IO protocol:
// Get the handle to our parent that provides the device I/O
// protocol interfaces to “MyDevice” (which has the device path
// of “MyDevicePath”)
EFI_DEVICE_IO_INTERFACE *IoFncs;
EFI_DEVICE_PATH *SearchPath;
SearchPath = MyDevicePath;
Status = LocateDevicePath (
&DeviceIoProtocol, // Protocol GUID
&SearchPath, // Device Path SearchKey
&DevHandle // Return EFI Handle
);
// Get the device I/O interfaces from the handle
Status = HandleProtocol (DevHandle, &DeviceIoProtocol, &IoFncs);
// Read 1 dword into Buffer from MyDevice’s I/O address
IoFncs->Io.Read (IoFncs, IO_UINT32, MyDeviceAddress, 1, &Buffer);
The call to LocateDevicePath() takes the Device Path of a device and returns the handle that
contains the DEVICE_IO protocol for the device. The handle is passed to HandleProtocol()
with a pointer to the EFI_GUID for DEVICE_IO protocol and a pointer to the DEVICE_IO
protocol is returned. The DEVICE_IO protocol pointer IoFncs is then used to do an I/O read to
a device.