iPXE
|
ATA block device. More...
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/list.h>
#include <ipxe/interface.h>
#include <ipxe/blockdev.h>
#include <ipxe/edd.h>
#include <ipxe/ata.h>
Go to the source code of this file.
Data Structures | |
struct | ata_device |
An ATA device. More... | |
struct | ata_command |
An ATA command. More... | |
struct | ata_command_type |
An ATA command type. More... | |
struct | ata_identify_private |
ATA IDENTIFY private data. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
int | ata_command (struct interface *control, struct interface *data, struct ata_cmd *command) |
Issue ATA command. More... | |
static | LIST_HEAD (ata_commands) |
List of all ATA commands. More... | |
static | __attribute__ ((always_inline)) |
Get reference to ATA device. More... | |
static void | atacmd_free (struct refcnt *refcnt) |
Free ATA command. More... | |
static void | atacmd_close (struct ata_command *atacmd, int rc) |
Close ATA command. More... | |
static void | atacmd_done (struct ata_command *atacmd, int rc) |
Handle ATA command completion. More... | |
static void | atacmd_data_buffer (struct ata_command *atacmd __unused, userptr_t buffer, size_t len, userptr_t *data, size_t *data_len) |
Use provided data buffer for ATA command. More... | |
static void | atacmd_data_none (struct ata_command *atacmd __unused, userptr_t buffer __unused, size_t len __unused, userptr_t *data __unused, size_t *data_len __unused) |
Use no data buffer for ATA command. More... | |
static void | atacmd_data_priv (struct ata_command *atacmd, userptr_t buffer __unused, size_t len __unused, userptr_t *data, size_t *data_len) |
Use private data buffer for ATA command. More... | |
static const char * | ata_model (struct ata_identity *identity) |
Return ATA model string (for debugging) More... | |
static void | atacmd_identify_done (struct ata_command *atacmd, int rc) |
Handle ATA IDENTIFY command completion. More... | |
static int | atadev_command (struct ata_device *atadev, struct interface *block, struct ata_command_type *type, uint64_t lba, unsigned int count, userptr_t buffer, size_t len) |
Create ATA command. More... | |
static int | atadev_read (struct ata_device *atadev, struct interface *block, uint64_t lba, unsigned int count, userptr_t buffer, size_t len) |
Issue ATA block read. More... | |
static int | atadev_write (struct ata_device *atadev, struct interface *block, uint64_t lba, unsigned int count, userptr_t buffer, size_t len) |
Issue ATA block write. More... | |
static int | atadev_read_capacity (struct ata_device *atadev, struct interface *block) |
Read ATA device capacity. More... | |
static void | atadev_close (struct ata_device *atadev, int rc) |
Close ATA device. More... | |
static int | atadev_edd_describe (struct ata_device *atadev, struct edd_interface_type *type, union edd_device_path *path) |
Describe ATA device using EDD. More... | |
int | ata_open (struct interface *block, struct interface *ata, unsigned int device, unsigned int max_count) |
Open ATA device. More... | |
Variables | |
static struct ata_command_type | atacmd_read |
ATA READ command type. More... | |
static struct ata_command_type | atacmd_write |
ATA WRITE command type. More... | |
static struct ata_command_type | atacmd_identify |
ATA IDENTITY command type. More... | |
static struct interface_operation | atacmd_block_op [] |
ATA command block interface operations. More... | |
static struct interface_descriptor | atacmd_block_desc |
ATA command block interface descriptor. More... | |
static struct interface_operation | atacmd_ata_op [] |
ATA command ATA interface operations. More... | |
static struct interface_descriptor | atacmd_ata_desc |
ATA command ATA interface descriptor. More... | |
static struct interface_operation | atadev_block_op [] |
ATA device block interface operations. More... | |
static struct interface_descriptor | atadev_block_desc |
ATA device block interface descriptor. More... | |
static struct interface_operation | atadev_ata_op [] |
ATA device ATA interface operations. More... | |
static struct interface_descriptor | atadev_ata_desc |
ATA device ATA interface descriptor. More... | |
ATA block device.
Definition in file ata.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
int ata_command | ( | struct interface * | control, |
struct interface * | data, | ||
struct ata_cmd * | command | ||
) |
Issue ATA command.
control | ATA control interface |
data | ATA data interface |
command | ATA command |
tag | Command tag, or negative error |
Definition at line 59 of file ata.c.
References ata_command_TYPE, control, data, dest, EOPNOTSUPP, intf_get_dest_op, intf_object(), intf_put(), op, and tag.
|
static |
List of all ATA commands.
|
inlinestatic |
Get reference to ATA device.
Get ATA command private data.
Drop reference to ATA command.
Get reference to ATA command.
Drop reference to ATA device.
atadev | ATA device |
atadev | ATA device |
atadev | ATA device |
atacmd | ATA command |
atacmd | ATA command |
atacmd | ATA command |
atacmd | ATA command |
priv | Private data |
Definition at line 181 of file ata.c.
References ref_get, and ata_device::refcnt.
|
static |
Free ATA command.
refcnt | Reference count |
Definition at line 235 of file ata.c.
References ata_command::atadev, container_of, free, ata_command::list, and list_del.
Referenced by atadev_command().
|
static |
Close ATA command.
atacmd | ATA command |
rc | Reason for close |
Definition at line 253 of file ata.c.
References ata_command::ata, ata_command::atadev, ata_command::block, DBGC, intf_shutdown(), rc, strerror(), and ata_command::tag.
Referenced by atacmd_identify_done(), atadev_close(), and atadev_command().
|
static |
Handle ATA command completion.
atacmd | ATA command |
rc | Reason for close |
Definition at line 272 of file ata.c.
References ata_command_type::done, rc, and ata_command::type.
|
static |
|
static |
Use private data buffer for ATA command.
atacmd | ATA command |
buffer | Available buffer |
len | Available buffer length |
data | Data buffer |
data_len | Data buffer length |
Definition at line 319 of file ata.c.
References data, data_len, ata_command_type::priv_len, ata_command::type, and virt_to_user().
|
static |
Return ATA model string (for debugging)
identify | ATA identity data |
model | Model string |
Definition at line 358 of file ata.c.
References bswap_16, and ata_identity::model.
Referenced by atacmd_identify_done().
|
static |
Handle ATA IDENTIFY command completion.
atacmd | ATA command |
rc | Reason for completion |
Definition at line 377 of file ata.c.
References ata_model(), ATA_SECTOR_SIZE, ATA_SUPPORTS_LBA48, atacmd_close(), ata_command::atadev, block_device_capacity::blksize, ata_command::block, block_capacity(), block_device_capacity::blocks, cpu_to_le16, DBGC, ata_device::lba48, ata_identity::lba48_sectors, ata_identity::lba_sectors, le32_to_cpu, le64_to_cpu, block_device_capacity::max_count, ata_device::max_count, priv, rc, and ata_identity::supports_lba48.
|
static |
Create ATA command.
atadev | ATA device |
block | Block data interface |
type | ATA command type |
lba | Starting logical block address |
count | Number of blocks to transfer |
buffer | Data buffer |
len | Length of data buffer |
rc | Return status code |
Definition at line 454 of file ata.c.
References ata_command::ata, ata_device::ata, ATA_DEV_LBA, ATA_DEV_OBSOLETE, ATA_SECTOR_SIZE, atacmd_ata_desc, atacmd_block_desc, atacmd_close(), atacmd_free(), ata_command::atadev, block, ata_command::block, buffer, count, DBGC, DBGC2, ata_device::device, EINVAL, ENOMEM, intf_init(), intf_plug_plug(), lba, ata_device::lba48, len, ata_command::list, list_add, memset(), ata_command_type::name, rc, ref_init, ref_put, ata_command::refcnt, strerror(), tag, ata_command::tag, type, ata_command::type, and zalloc().
Referenced by atadev_read(), atadev_read_capacity(), and atadev_write().
|
static |
Issue ATA block read.
atadev | ATA device |
block | Block data interface |
lba | Starting logical block address |
count | Number of blocks to transfer |
buffer | Data buffer |
len | Length of data buffer |
rc | Return status code |
Definition at line 543 of file ata.c.
References atacmd_read, atadev_command(), block, buffer, count, lba, and len.
|
static |
Issue ATA block write.
atadev | ATA device |
block | Block data interface |
lba | Starting logical block address |
count | Number of blocks to transfer |
buffer | Data buffer |
len | Length of data buffer |
rc | Return status code |
Definition at line 562 of file ata.c.
References atacmd_write, atadev_command(), block, buffer, count, lba, and len.
|
static |
Read ATA device capacity.
atadev | ATA device |
block | Block data interface |
rc | Return status code |
Definition at line 577 of file ata.c.
References assert(), ATA_SECTOR_SIZE, atacmd_identify, atadev_command(), block, ata_command_type::priv_len, and UNULL.
|
static |
Close ATA device.
atadev | ATA device |
rc | Reason for close |
Definition at line 593 of file ata.c.
References ata_device::ata, atacmd_close(), ata_command::atadev, ata_device::block, intf_shutdown(), ata_command::list, list_for_each_entry_safe, rc, and tmp.
|
static |
Describe ATA device using EDD.
atadev | ATA device |
type | EDD interface type |
path | EDD device path |
rc | Return status code |
Definition at line 619 of file ata.c.
References ATA_DEV_SLAVE, ata_command::atadev, cpu_to_le64, ata_device::device, EDD_INTF_TYPE_ATA, edd_device_path::slave, and type.
int ata_open | ( | struct interface * | block, |
struct interface * | ata, | ||
unsigned int | device, | ||
unsigned int | max_count | ||
) |
Open ATA device.
block | Block control interface |
ata | ATA control interface |
device | ATA device number |
max_count | Maximum number of blocks per single transfer |
rc | Return status code |
Definition at line 662 of file ata.c.
References ata_device::ata, atadev_ata_desc, atadev_block_desc, block, ata_device::block, device, ata_device::device, ENOMEM, intf_init(), intf_plug_plug(), ata_device::max_count, NULL, ref_init, ref_put, ata_device::refcnt, and zalloc().
Referenced by aoedev_open().
|
static |
ATA READ command type.
Definition at line 327 of file ata.c.
Referenced by atadev_read().
|
static |
ATA WRITE command type.
Definition at line 337 of file ata.c.
Referenced by atadev_write().
|
static |
ATA IDENTITY command type.
Definition at line 412 of file ata.c.
Referenced by atadev_read_capacity().
|
static |
ATA command block interface operations.
|
static |
ATA command block interface descriptor.
Definition at line 428 of file ata.c.
Referenced by atadev_command().
|
static |
ATA command ATA interface operations.
|
static |
ATA command ATA interface descriptor.
Definition at line 438 of file ata.c.
Referenced by atadev_command().
|
static |
ATA device block interface operations.
|
static |
ATA device block interface descriptor.
Definition at line 639 of file ata.c.
Referenced by ata_open().
|
static |
ATA device ATA interface operations.
|
static |
ATA device ATA interface descriptor.
Definition at line 649 of file ata.c.
Referenced by ata_open().