2007-07-16 07:48:11 +02:00
|
|
|
/** @file
|
2008-07-18 11:49:25 +02:00
|
|
|
Master header file for DiskIo driver. It includes the module private defininitions.
|
2007-07-16 07:48:11 +02:00
|
|
|
|
2008-04-08 06:46:45 +02:00
|
|
|
Copyright (c) 2006 - 2008, Intel Corporation. <BR>
|
|
|
|
All rights reserved. This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
2007-07-16 07:48:11 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
2008-05-14 08:07:07 +02:00
|
|
|
#ifndef _DISK_IO_H_
|
|
|
|
#define _DISK_IO_H_
|
2007-07-16 07:48:11 +02:00
|
|
|
|
|
|
|
#include <Uefi.h>
|
|
|
|
#include <Protocol/BlockIo.h>
|
|
|
|
#include <Protocol/ComponentName.h>
|
|
|
|
#include <Protocol/DriverBinding.h>
|
|
|
|
#include <Protocol/DiskIo.h>
|
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/UefiDriverEntryPoint.h>
|
|
|
|
#include <Library/UefiLib.h>
|
|
|
|
#include <Library/BaseLib.h>
|
|
|
|
#include <Library/BaseMemoryLib.h>
|
|
|
|
#include <Library/MemoryAllocationLib.h>
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
|
|
|
|
|
2008-12-23 17:20:43 +01:00
|
|
|
#define DATA_BUFFER_BLOCK_NUM 64
|
2007-07-16 07:48:11 +02:00
|
|
|
|
2008-12-23 17:20:43 +01:00
|
|
|
#define DISK_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('d', 's', 'k', 'I')
|
2007-07-16 07:48:11 +02:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
UINTN Signature;
|
|
|
|
EFI_DISK_IO_PROTOCOL DiskIo;
|
|
|
|
EFI_BLOCK_IO_PROTOCOL *BlockIo;
|
|
|
|
} DISK_IO_PRIVATE_DATA;
|
|
|
|
|
|
|
|
#define DISK_IO_PRIVATE_DATA_FROM_THIS(a) CR (a, DISK_IO_PRIVATE_DATA, DiskIo, DISK_IO_PRIVATE_DATA_SIGNATURE)
|
|
|
|
|
|
|
|
//
|
|
|
|
// Global Variables
|
|
|
|
//
|
2007-09-30 05:01:48 +02:00
|
|
|
extern EFI_DRIVER_BINDING_PROTOCOL gDiskIoDriverBinding;
|
|
|
|
extern EFI_COMPONENT_NAME_PROTOCOL gDiskIoComponentName;
|
|
|
|
extern EFI_COMPONENT_NAME2_PROTOCOL gDiskIoComponentName2;
|
2007-07-16 07:48:11 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Prototypes
|
|
|
|
// Driver model protocol interface
|
|
|
|
//
|
2008-05-08 06:17:44 +02:00
|
|
|
/**
|
|
|
|
Test to see if this driver supports ControllerHandle.
|
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param ControllerHandle Handle of device to test
|
|
|
|
@param RemainingDevicePath Optional parameter use to pick a specific child
|
|
|
|
device to start.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS This driver supports this device
|
|
|
|
@retval EFI_ALREADY_STARTED This driver is already running on this device
|
|
|
|
@retval other This driver does not support this device
|
|
|
|
|
|
|
|
**/
|
2007-07-16 07:48:11 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DiskIoDriverBindingSupported (
|
2008-05-14 08:07:07 +02:00
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
2007-07-16 07:48:11 +02:00
|
|
|
);
|
|
|
|
|
2008-05-08 06:17:44 +02:00
|
|
|
/**
|
|
|
|
Start this driver on ControllerHandle by opening a Block IO protocol and
|
|
|
|
installing a Disk IO protocol on ControllerHandle.
|
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param ControllerHandle Handle of device to bind driver to
|
|
|
|
@param RemainingDevicePath Optional parameter use to pick a specific child
|
|
|
|
device to start.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS This driver is added to ControllerHandle
|
|
|
|
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
|
|
|
|
@retval other This driver does not support this device
|
|
|
|
|
|
|
|
**/
|
2007-07-16 07:48:11 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DiskIoDriverBindingStart (
|
2008-05-14 08:07:07 +02:00
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
2007-07-16 07:48:11 +02:00
|
|
|
);
|
|
|
|
|
2008-05-08 06:17:44 +02:00
|
|
|
/**
|
|
|
|
Stop this driver on ControllerHandle by removing Disk IO protocol and closing
|
|
|
|
the Block IO protocol on ControllerHandle.
|
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param ControllerHandle Handle of device to stop driver on
|
|
|
|
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
|
|
|
|
children is zero stop the entire bus driver.
|
|
|
|
@param ChildHandleBuffer List of Child Handles to Stop.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS This driver is removed ControllerHandle
|
|
|
|
@retval other This driver was not removed from this device
|
|
|
|
|
|
|
|
**/
|
2007-07-16 07:48:11 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DiskIoDriverBindingStop (
|
|
|
|
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN UINTN NumberOfChildren,
|
|
|
|
IN EFI_HANDLE *ChildHandleBuffer
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Disk I/O Protocol Interface
|
|
|
|
//
|
2008-05-08 06:17:44 +02:00
|
|
|
/**
|
|
|
|
Read BufferSize bytes from Offset into Buffer.
|
|
|
|
Reads may support reads that are not aligned on
|
|
|
|
sector boundaries. There are three cases:
|
|
|
|
UnderRun - The first byte is not on a sector boundary or the read request is
|
|
|
|
less than a sector in length.
|
|
|
|
Aligned - A read of N contiguous sectors.
|
|
|
|
OverRun - The last byte is not on a sector boundary.
|
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param MediaId Id of the media, changes every time the media is replaced.
|
|
|
|
@param Offset The starting byte offset to read from
|
|
|
|
@param BufferSize Size of Buffer
|
|
|
|
@param Buffer Buffer containing read data
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The data was read correctly from the device.
|
|
|
|
@retval EFI_DEVICE_ERROR The device reported an error while performing the read.
|
|
|
|
@retval EFI_NO_MEDIA There is no media in the device.
|
|
|
|
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
|
|
|
|
@retval EFI_INVALID_PARAMETER The read request contains device addresses that are not
|
|
|
|
valid for the device.
|
|
|
|
|
|
|
|
**/
|
2007-07-16 07:48:11 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DiskIoReadDisk (
|
|
|
|
IN EFI_DISK_IO_PROTOCOL *This,
|
|
|
|
IN UINT32 MediaId,
|
|
|
|
IN UINT64 Offset,
|
|
|
|
IN UINTN BufferSize,
|
|
|
|
OUT VOID *Buffer
|
|
|
|
);
|
|
|
|
|
2008-05-08 06:17:44 +02:00
|
|
|
/**
|
2008-07-18 11:49:25 +02:00
|
|
|
Writes BufferSize bytes from Buffer into Offset.
|
2008-05-08 06:17:44 +02:00
|
|
|
Writes may require a read modify write to support writes that are not
|
|
|
|
aligned on sector boundaries. There are three cases:
|
|
|
|
UnderRun - The first byte is not on a sector boundary or the write request
|
|
|
|
is less than a sector in length. Read modify write is required.
|
|
|
|
Aligned - A write of N contiguous sectors.
|
|
|
|
OverRun - The last byte is not on a sector boundary. Read modified write
|
|
|
|
required.
|
|
|
|
|
|
|
|
@param This Protocol instance pointer.
|
|
|
|
@param MediaId Id of the media, changes every time the media is replaced.
|
|
|
|
@param Offset The starting byte offset to read from
|
|
|
|
@param BufferSize Size of Buffer
|
|
|
|
@param Buffer Buffer containing read data
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The data was written correctly to the device.
|
|
|
|
@retval EFI_WRITE_PROTECTED The device can not be written to.
|
|
|
|
@retval EFI_DEVICE_ERROR The device reported an error while performing the write.
|
|
|
|
@retval EFI_NO_MEDIA There is no media in the device.
|
|
|
|
@retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.
|
|
|
|
@retval EFI_INVALID_PARAMETER The write request contains device addresses that are not
|
|
|
|
valid for the device.
|
|
|
|
|
|
|
|
**/
|
2007-07-16 07:48:11 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DiskIoWriteDisk (
|
|
|
|
IN EFI_DISK_IO_PROTOCOL *This,
|
|
|
|
IN UINT32 MediaId,
|
|
|
|
IN UINT64 Offset,
|
|
|
|
IN UINTN BufferSize,
|
|
|
|
IN VOID *Buffer
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// EFI Component Name Functions
|
|
|
|
//
|
2007-09-30 05:01:48 +02:00
|
|
|
/**
|
|
|
|
Retrieves a Unicode string that is the user readable name of the driver.
|
|
|
|
|
|
|
|
This function retrieves the user readable name of a driver in the form of a
|
|
|
|
Unicode string. If the driver specified by This has a user readable name in
|
|
|
|
the language specified by Language, then a pointer to the driver name is
|
|
|
|
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
|
|
|
|
by This does not support the language specified by Language,
|
|
|
|
then EFI_UNSUPPORTED is returned.
|
|
|
|
|
|
|
|
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
|
|
|
EFI_COMPONENT_NAME_PROTOCOL instance.
|
|
|
|
|
|
|
|
@param Language[in] A pointer to a Null-terminated ASCII string
|
|
|
|
array indicating the language. This is the
|
|
|
|
language of the driver name that the caller is
|
|
|
|
requesting, and it must match one of the
|
|
|
|
languages specified in SupportedLanguages. The
|
|
|
|
number of languages supported by a driver is up
|
|
|
|
to the driver writer. Language is specified
|
2009-04-30 07:32:11 +02:00
|
|
|
in RFC 4646 or ISO 639-2 language code format.
|
2007-09-30 05:01:48 +02:00
|
|
|
|
|
|
|
@param DriverName[out] A pointer to the Unicode string to return.
|
|
|
|
This Unicode string is the name of the
|
|
|
|
driver specified by This in the language
|
|
|
|
specified by Language.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The Unicode string for the Driver specified by
|
|
|
|
This and the language specified by Language was
|
|
|
|
returned in DriverName.
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Language is NULL.
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER DriverName is NULL.
|
|
|
|
|
|
|
|
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
|
|
|
the language specified by Language.
|
|
|
|
|
|
|
|
**/
|
2007-07-16 07:48:11 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DiskIoComponentNameGetDriverName (
|
|
|
|
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
|
|
IN CHAR8 *Language,
|
|
|
|
OUT CHAR16 **DriverName
|
|
|
|
);
|
|
|
|
|
2007-09-30 05:01:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
Retrieves a Unicode string that is the user readable name of the controller
|
|
|
|
that is being managed by a driver.
|
|
|
|
|
|
|
|
This function retrieves the user readable name of the controller specified by
|
|
|
|
ControllerHandle and ChildHandle in the form of a Unicode string. If the
|
|
|
|
driver specified by This has a user readable name in the language specified by
|
|
|
|
Language, then a pointer to the controller name is returned in ControllerName,
|
|
|
|
and EFI_SUCCESS is returned. If the driver specified by This is not currently
|
|
|
|
managing the controller specified by ControllerHandle and ChildHandle,
|
|
|
|
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
|
|
|
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
|
|
|
|
|
|
|
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
|
|
|
EFI_COMPONENT_NAME_PROTOCOL instance.
|
|
|
|
|
|
|
|
@param ControllerHandle[in] The handle of a controller that the driver
|
|
|
|
specified by This is managing. This handle
|
|
|
|
specifies the controller whose name is to be
|
|
|
|
returned.
|
|
|
|
|
|
|
|
@param ChildHandle[in] The handle of the child controller to retrieve
|
|
|
|
the name of. This is an optional parameter that
|
|
|
|
may be NULL. It will be NULL for device
|
|
|
|
drivers. It will also be NULL for a bus drivers
|
|
|
|
that wish to retrieve the name of the bus
|
|
|
|
controller. It will not be NULL for a bus
|
|
|
|
driver that wishes to retrieve the name of a
|
|
|
|
child controller.
|
|
|
|
|
|
|
|
@param Language[in] A pointer to a Null-terminated ASCII string
|
|
|
|
array indicating the language. This is the
|
|
|
|
language of the driver name that the caller is
|
|
|
|
requesting, and it must match one of the
|
|
|
|
languages specified in SupportedLanguages. The
|
|
|
|
number of languages supported by a driver is up
|
|
|
|
to the driver writer. Language is specified in
|
2009-04-30 07:32:11 +02:00
|
|
|
RFC 4646 or ISO 639-2 language code format.
|
2007-09-30 05:01:48 +02:00
|
|
|
|
|
|
|
@param ControllerName[out] A pointer to the Unicode string to return.
|
|
|
|
This Unicode string is the name of the
|
|
|
|
controller specified by ControllerHandle and
|
|
|
|
ChildHandle in the language specified by
|
|
|
|
Language from the point of view of the driver
|
|
|
|
specified by This.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The Unicode string for the user readable name in
|
|
|
|
the language specified by Language for the
|
|
|
|
driver specified by This was returned in
|
|
|
|
DriverName.
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
|
|
|
|
EFI_HANDLE.
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER Language is NULL.
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
|
|
|
|
|
|
|
@retval EFI_UNSUPPORTED The driver specified by This is not currently
|
|
|
|
managing the controller specified by
|
|
|
|
ControllerHandle and ChildHandle.
|
|
|
|
|
|
|
|
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
|
|
|
the language specified by Language.
|
|
|
|
|
|
|
|
**/
|
2007-07-16 07:48:11 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
DiskIoComponentNameGetControllerName (
|
|
|
|
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
|
|
|
IN EFI_HANDLE ControllerHandle,
|
|
|
|
IN EFI_HANDLE ChildHandle OPTIONAL,
|
|
|
|
IN CHAR8 *Language,
|
|
|
|
OUT CHAR16 **ControllerName
|
|
|
|
);
|
|
|
|
|
2007-09-30 05:01:48 +02:00
|
|
|
|
2007-07-16 07:48:11 +02:00
|
|
|
#endif
|