EFI DISK IO PROTOCOL

From PhoenixWiki

Jump to: navigation, search

This protocol is used to abstract Block I/O interfaces.

Contents

GUID

#define EFI_DISK_IO_PROTOCOL_GUID \
  {0xCE345171,0xBA0B,0x11d2,0x8e,0x4F,0x00,0xa0,0xc9,0x69,0x72,0x3b}

Protocol Interface Structure

typedef struct _EFI_DISK_IO_PROTOCOL {
  UINT64         Revision;
  EFI_DISK_READ  ReadDisk;
  EFI_DISK_WRITE WriteDisk;
} EFI_DISK_IO_PROTOCOL;
#define EFI_DISK_IO_PROTOCOL_REVISION 0x00010000

Members

Member Description
Revision The revision to which the disk I/O interface adheres. All future revisions must be backwards compatible. If a future version is not backwards compatible, it is not the same GUID.
ReadDisk Reads data from the disk.
WriteDisk Writes data to the disk.

Description

The EFI_DISK_IO_PROTOCOL is used to control block I/O interfaces.

The disk I/O functions allow I/O operations that need not be on the underlying device’s block boundaries or alignment requirements. This is done by copying the data to/from internal buffers as needed to provide the proper requests to the block I/O device. Outstanding write buffer data is flushed by using the FlushBlocks() function of the EFI_BLOCK_IO_PROTOCOL on the device handle.

The firmware automatically adds an EFI_DISK_IO_PROTOCOL interface to any EFI_BLOCK_IO_PROTOCOL interface that is produced. It also adds file system, or logical block I/O, interfaces to any EFI_DISK_IO_PROTOCOL interface that contains any recognized file system or logical block I/O devices. The firmware must automatically support the following required formats:

  • The EFI FAT12, FAT16, and FAT32 file system type.
  • The legacy master boot record partition block. (The presence of this on any block I/O device is optional, but if it is present the firmware is responsible for allocating a logical device for each partition).
  • The extended partition record partition block.
  • The El Torito logical block devices.

ReadDisk()

Reads a specified number of bytes from a device.

Prototype

typedef
EFI_STATUS
(EFIAPI *EFI_DISK_READ) (
  IN EFI_DISK_IO_PROTOCOL *This,
  IN UINT32 MediaId,
  IN UINT64 Offset,
  IN UINTN BufferSize,
  OUT VOID *Buffer);

Parameters

Parameter Description
This Indicates a pointer to the calling context.
MediaId ID of the medium to be read.
Offset The starting byte offset on the logical block I/O device to read from.
BufferSize The size in bytes of Buffer. The number of bytes to read from the device.
Buffer A pointer to the destination buffer for the data. The caller is responsible for either having implicit or explicit ownership of the buffer.

Description
The ReadDisk() function reads the number of bytes specified by BufferSize from the device. All the bytes are read, or an error is returned. If there is no medium in the device, the function returns EFI_NO_MEDIA. If the MediaId is not the ID of the medium currently in the device, the function returns EFI_MEDIA_CHANGED.

Status Codes Returned

Parameter Description
EFI_SUCCESS The data was read correctly from the device.
EFI_DEVICE_ERROR The device reported an error while performing the read operation.
EFI_NO_MEDIA There is no medium in the device.
EFI_MEDIA_CHANGED The MediaId is not for the current medium.
EFI_INVALID_PARAMETER The read request contains device addresses that are not valid for the device.

WriteDisk()

Writes a specified number of bytes to a device.

Prototype

typedef
EFI_STATUS
(EFIAPI *EFI_DISK_WRITE) (
  IN EFI_DISK_IO_PROTOCOL *This,
  IN UINT32 MediaId,
  IN UINT64 Offset,
  IN UINTN BufferSize,
  IN VOID *Buffer);

Parameters

Parameter Description
This Indicates a pointer to the calling context.
MediaId ID of the medium to be written.
Offset The starting byte offset on the logical block I/O device to write.
BufferSize The size in bytes of Buffer. The number of bytes to write to the device.
Buffer A pointer to the buffer containing the data to be written.

Description
The WriteDisk() function writes the number of bytes specified by BufferSize to the device. All bytes are written, or an error is returned. If there is no medium in the device, the function returns EFI_NO_MEDIA. If the MediaId is not the ID of the medium currently in the device, the function returns EFI_MEDIA_CHANGED.

Status Codes Returned

Status Code Description
EFI_SUCCESS The data was written correctly to the device.
EFI_WRITE_PROTECTED The device cannot be written to.
EFI_NO_MEDIA There is no medium in the device.
EFI_MEDIA_CHANGED The MediaId is not for the current medium.
EFI_DEVICE_ERROR The device reported an error while performing the write operation.
EFI_INVALID_PARAMETER The write request contains device addresses that are not valid for the device.

Copyright (C) 2008-2009 Phoenix Technologies Ltd. All Rights Reserved. Portions copyright (C) 2008 UEFI Forum, Inc. Used with permission.

Personal tools