152 size_t *data_in_len );
165 size_t *data_out_len );
241 atadev_put ( atacmd->
atadev );
257 DBGC ( atadev,
"ATA %p tag %08x closed: %s\n",
361 char text[
sizeof ( identity->
model ) + 1 ];
365 for ( i = 0 ; i < (
sizeof ( identity->
model ) / 2 ) ; i++ )
398 DBGC ( atadev,
"ATA %p is a %s\n", atadev,
ata_model ( identity ) );
399 DBGC ( atadev,
"ATA %p has %#llx blocks (%ld MB) and uses %s\n",
401 ( (
signed long ) ( capacity.
blocks >> 11 ) ),
402 ( atadev->
lba48 ?
"LBA48" :
"LBA" ) );
465 atacmd =
zalloc (
sizeof ( *atacmd ) +
type->priv_len );
474 atacmd->
atadev = atadev_get ( atadev );
480 DBGC ( atadev,
"ATA %p tag %08x buffer length mismatch (count " 481 "%d len %zd)\n", atadev, atacmd->
tag,
count,
len );
492 if ( ! atadev->
lba48 )
505 DBGC ( atadev,
"ATA %p tag %08x could not issue command: %s\n",
511 DBGC2 ( atadev,
"ATA %p tag %08x %s cmd %02x dev %02x LBA%s %08llx " 512 "count %04x\n", atadev, atacmd->
tag, atacmd->
type->
name,
514 (
command.cb.lba48 ?
"48" :
"" ),
515 (
unsigned long long )
command.cb.lba.native,
605 atacmd_get ( atacmd );
607 atacmd_put ( atacmd );
663 unsigned int device,
unsigned int max_count ) {
667 atadev =
zalloc (
sizeof ( *atadev ) );
int block_write(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, userptr_t buffer, size_t len)
Write to block device.
#define EINVAL
Invalid argument.
An object interface operation.
struct arbelprm_rc_send_wqe rc
void intf_close(struct interface *intf, int rc)
Close an object interface.
static void atacmd_done(struct ata_command *atacmd, int rc)
Handle ATA command completion.
void(* done)(struct ata_command *atacmd, int rc)
Handle ATA command completion.
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
unsigned int max_count
Maximum number of blocks per single transfer.
#define EDD_INTF_TYPE_ATA
EDD ATA interface type.
uint8_t priv[0]
Private data.
#define le32_to_cpu(value)
static void atacmd_free(struct refcnt *refcnt)
Free ATA command.
struct ata_device * atadev
ATA device.
#define list_add(new, head)
Add a new entry to the head of a list.
#define ref_init(refcnt, free)
Initialise a reference counter.
void block_capacity(struct interface *intf, struct block_device_capacity *capacity)
Report block device capacity.
uint32_t type
Operating system type.
static void atacmd_close(struct ata_command *atacmd, int rc)
Close ATA command.
int edd_describe(struct interface *intf, struct edd_interface_type *type, union edd_device_path *path)
Describe a disk device using EDD.
static int atadev_read_capacity(struct ata_device *atadev, struct interface *block)
Read ATA device capacity.
uint8_t cmd_lba
Command for non-LBA48-capable devices.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
unsigned long long uint64_t
size_t priv_len
Additional working space.
#define cpu_to_le64(value)
uint32_t data_len
Microcode data size (or 0 to indicate 2000 bytes)
int block_read(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, userptr_t buffer, size_t len)
Read from block device.
Structure returned by ATA IDENTIFY command.
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.
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
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.
unsigned int device
Device number.
void(* data_in)(struct ata_command *atacmd, userptr_t buffer, size_t len, userptr_t *data_in, size_t *data_in_len)
Calculate data-in buffer.
uint16_t device
Device ID.
static struct interface_descriptor atadev_block_desc
ATA device block interface descriptor.
void(* data_out)(struct ata_command *atacmd, userptr_t buffer, size_t len, userptr_t *data_out, size_t *data_out_len)
Calculate data-out buffer.
static struct interface_operation atacmd_block_op[]
ATA command block interface operations.
#define ATA_CMD_WRITE
"Write sectors" command
static __attribute__((always_inline))
Get reference to ATA device.
ATA IDENTIFY private data.
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
A doubly-linked list entry (or list head)
static struct interface_descriptor atacmd_ata_desc
ATA command ATA interface descriptor.
struct refcnt refcnt
Reference count.
static struct interface_operation atadev_block_op[]
ATA device block interface operations.
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.
#define list_del(list)
Delete an entry from a list.
#define ENOMEM
Not enough space.
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.
uint32_t userptr_t
A pointer to a user buffer.
struct interface block
Block control interface.
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
#define ATA_CMD_IDENTIFY
"Identify" command
struct ata_identity identity
Identity data.
#define ATA_CMD_WRITE_EXT
"Write sectors (ext)" command
#define __unused
Declare a variable or data structure as unused.
An ATA command information unit.
uint16_t count
Number of entries.
#define ATA_DEV_OBSOLETE
Obsolete bits in the ATA device register.
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.
struct list_head list
List of ATA commands.
uint64_t blocks
Total number of blocks.
struct refcnt refcnt
Reference count.
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
static int atadev_edd_describe(struct ata_device *atadev, struct edd_interface_type *type, union edd_device_path *path)
Describe ATA device using EDD.
An object interface descriptor.
char * strerror(int errno)
Retrieve string representation of error number.
static struct ata_command_type atacmd_identify
ATA IDENTITY command type.
static void(* free)(struct refcnt *refcnt))
void * zalloc(size_t size)
Allocate cleared memory.
static LIST_HEAD(ata_commands)
List of all ATA commands.
#define ref_get(refcnt)
Get additional reference to object.
unsigned int max_count
Maximum number of blocks per single transfer.
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
#define EOPNOTSUPP
Operation not supported on socket.
struct interface ata
ATA data interface.
int lba48
Device uses LBA48 extended addressing.
uint64_t lba
Starting block number.
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.
#define ATA_CMD_READ_EXT
"Read sectors (ext)" command
#define ATA_DEV_LBA
LBA flag in the ATA device register.
static struct interface_operation atacmd_ata_op[]
ATA command ATA interface operations.
static const char * ata_model(struct ata_identity *identity)
Return ATA model string (for debugging)
struct interface ata
ATA control interface.
int ata_command(struct interface *control, struct interface *data, struct ata_cmd *command)
Issue ATA command.
static uint16_t struct vmbus_xfer_pages_operations * op
static void atacmd_identify_done(struct ata_command *atacmd, int rc)
Handle ATA IDENTIFY command completion.
static struct interface_operation atadev_ata_op[]
ATA device ATA interface operations.
#define UNULL
Equivalent of NULL for user pointers.
static struct ata_command_type atacmd_read
ATA READ command type.
#define ata_command_TYPE(object_type)
uint8_t block[3][8]
DES-encrypted blocks.
static struct tlan_private * priv
static struct interface_descriptor atadev_ata_desc
ATA device ATA interface descriptor.
struct ata_command_type * type
Command type.
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
userptr_t virt_to_user(volatile const void *addr)
Convert virtual address to user pointer.
#define cpu_to_le16(value)
if(len >=6 *4) __asm__ __volatile__("movsl" if(len >=5 *4) __asm__ __volatile__("movsl" if(len >=4 *4) __asm__ __volatile__("movsl" if(len >=3 *4) __asm__ __volatile__("movsl" if(len >=2 *4) __asm__ __volatile__("movsl" if(len >=1 *4) __asm__ __volatile__("movsl" if((len % 4) >=2) __asm__ __volatile__("movsw" if((len % 2) >=1) __asm__ __volatile__("movsb" return dest
uint8_t data[48]
Additional event data.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
#define ATA_CMD_READ
"Read sectors" command
int ata_open(struct interface *block, struct interface *ata, unsigned int device, unsigned int max_count)
Open ATA device.
#define INTF_DESC_PASSTHRU(object_type, intf, operations, passthru)
Define an object interface descriptor with pass-through interface.
Enhanced Disk Drive specification.
int block_read_capacity(struct interface *control, struct interface *data)
Read block device capacity.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
#define le64_to_cpu(value)
uint8_t cmd_lba48
Command for LBA48-capable devices.
uint64_t tag
Identity tag.
#define ATA_SUPPORTS_LBA48
Supports LBA48 flag.
#define ATA_DEV_SLAVE
Slave ("device 1") flag in the ATA device register.
struct interface block
Block data interface.
#define NULL
NULL pointer (VOID *)
static void atadev_close(struct ata_device *atadev, int rc)
Close ATA device.
static struct interface_descriptor atacmd_block_desc
ATA command block interface descriptor.
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
static struct ata_command_type atacmd_write
ATA WRITE command type.
#define ref_put(refcnt)
Drop reference to object.
size_t blksize
Block size.
void * memset(void *dest, int character, size_t len) __nonnull
#define ATA_SECTOR_SIZE
ATA sector size.