iPXE
ata.h File Reference

ATA devices. More...

#include <stdint.h>
#include <ipxe/interface.h>

Go to the source code of this file.

Data Structures

union  ata_lba
 An ATA Logical Block Address. More...
union  ata_fifo
 An ATA 2-byte FIFO register. More...
struct  ata_cb
 ATA command block. More...
struct  ata_identity
 Structure returned by ATA IDENTIFY command. More...
struct  ata_cmd
 An ATA command information unit. More...

Macros

#define ATA_DEV_OBSOLETE   0xa0
 Obsolete bits in the ATA device register.
#define ATA_DEV_LBA   0x40
 LBA flag in the ATA device register.
#define ATA_DEV_SLAVE   0x10
 Slave ("device 1") flag in the ATA device register.
#define ATA_DEV_MASTER   0x00
 Master ("device 0") flag in the ATA device register.
#define ATA_DEV_MASK   0xf0
 Mask of non-LBA portion of device register.
#define ATA_CMD_READ   0x20
 "Read sectors" command
#define ATA_CMD_READ_EXT   0x24
 "Read sectors (ext)" command
#define ATA_CMD_WRITE   0x30
 "Write sectors" command
#define ATA_CMD_WRITE_EXT   0x34
 "Write sectors (ext)" command
#define ATA_CMD_IDENTIFY   0xec
 "Identify" command
#define ATA_STAT_ERR   0x01
 Command completed in error.
#define ATA_SUPPORTS_LBA48   ( 1 << 10 )
 Supports LBA48 flag.
#define ATA_SECTOR_SIZE   512
 ATA sector size.
#define ata_command_TYPE(object_type)

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
int ata_command (struct interface *control, struct interface *data, struct ata_cmd *command)
 Issue ATA command.
int ata_open (struct interface *block, struct interface *ata, unsigned int device, unsigned int max_count)
 Open ATA device.

Detailed Description

ATA devices.

Definition in file ata.h.

Macro Definition Documentation

◆ ATA_DEV_OBSOLETE

#define ATA_DEV_OBSOLETE   0xa0

Obsolete bits in the ATA device register.

Definition at line 111 of file ata.h.

Referenced by atadev_command().

◆ ATA_DEV_LBA

#define ATA_DEV_LBA   0x40

LBA flag in the ATA device register.

Definition at line 114 of file ata.h.

Referenced by atadev_command().

◆ ATA_DEV_SLAVE

#define ATA_DEV_SLAVE   0x10

Slave ("device 1") flag in the ATA device register.

Definition at line 117 of file ata.h.

Referenced by aoecmd_ata_cmd(), and atadev_edd_describe().

◆ ATA_DEV_MASTER

#define ATA_DEV_MASTER   0x00

Master ("device 0") flag in the ATA device register.

Definition at line 120 of file ata.h.

Referenced by aoedev_open().

◆ ATA_DEV_MASK

#define ATA_DEV_MASK   0xf0

Mask of non-LBA portion of device register.

Definition at line 123 of file ata.h.

Referenced by aoecmd_ata_cmd().

◆ ATA_CMD_READ

#define ATA_CMD_READ   0x20

"Read sectors" command

Definition at line 126 of file ata.h.

◆ ATA_CMD_READ_EXT

#define ATA_CMD_READ_EXT   0x24

"Read sectors (ext)" command

Definition at line 129 of file ata.h.

◆ ATA_CMD_WRITE

#define ATA_CMD_WRITE   0x30

"Write sectors" command

Definition at line 132 of file ata.h.

◆ ATA_CMD_WRITE_EXT

#define ATA_CMD_WRITE_EXT   0x34

"Write sectors (ext)" command

Definition at line 135 of file ata.h.

◆ ATA_CMD_IDENTIFY

#define ATA_CMD_IDENTIFY   0xec

"Identify" command

Definition at line 138 of file ata.h.

◆ ATA_STAT_ERR

#define ATA_STAT_ERR   0x01

Command completed in error.

Definition at line 141 of file ata.h.

Referenced by aoecmd_ata_rsp().

◆ ATA_SUPPORTS_LBA48

#define ATA_SUPPORTS_LBA48   ( 1 << 10 )

Supports LBA48 flag.

Definition at line 162 of file ata.h.

Referenced by atacmd_identify_done().

◆ ATA_SECTOR_SIZE

#define ATA_SECTOR_SIZE   512

ATA sector size.

Definition at line 165 of file ata.h.

Referenced by atacmd_identify_done(), atadev_command(), and atadev_read_capacity().

◆ ata_command_TYPE

#define ata_command_TYPE ( object_type)
Value:
typeof ( int ( object_type, struct interface *data, \
struct ata_cmd *command ) )
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition acpi.c:48
uint8_t data[48]
Additional event data.
Definition ena.h:11
An ATA command information unit.
Definition ata.h:168
A command-line command.
Definition command.h:10
An object interface.
Definition interface.h:125

Definition at line 197 of file ata.h.

197#define ata_command_TYPE( object_type ) \
198 typeof ( int ( object_type, struct interface *data, \
199 struct ata_cmd *command ) )

Referenced by ata_command().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ ata_command()

int ata_command ( struct interface * control,
struct interface * data,
struct ata_cmd * command )
extern

Issue ATA command.

Parameters
controlATA control interface
dataATA data interface
commandATA command
Return values
tagCommand tag, or negative error

Definition at line 60 of file ata.c.

61 {
62 struct interface *dest;
63 ata_command_TYPE ( void * ) *op =
65 void *object = intf_object ( dest );
66 int tag;
67
68 if ( op ) {
69 tag = op ( object, data, command );
70 } else {
71 /* Default is to fail to issue the command */
72 tag = -EOPNOTSUPP;
73 }
74
75 intf_put ( dest );
76 return tag;
77}
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" retur dest)
Definition string.h:151
#define ata_command_TYPE(object_type)
Definition ata.h:197
uint64_t tag
Identity tag.
Definition edd.h:1
#define EOPNOTSUPP
Operation not supported on socket.
Definition errno.h:605
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition interface.c:160
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition interface.c:150
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition interface.h:270
uint32_t control
Control.
Definition myson.h:3
static uint16_t struct vmbus_xfer_pages_operations * op
Definition netvsc.h:327
An ATA command.
Definition ata.c:110

References ata_command_TYPE, control, data, dest, EOPNOTSUPP, intf_get_dest_op, intf_object(), intf_put(), op, and tag.

◆ ata_open()

int ata_open ( struct interface * block,
struct interface * ata,
unsigned int device,
unsigned int max_count )
extern

Open ATA device.

Parameters
blockBlock control interface
ataATA control interface
deviceATA device number
max_countMaximum number of blocks per single transfer
Return values
rcReturn status code

Definition at line 663 of file ata.c.

664 {
665 struct ata_device *atadev;
666
667 /* Allocate and initialise structure */
668 atadev = zalloc ( sizeof ( *atadev ) );
669 if ( ! atadev )
670 return -ENOMEM;
671 ref_init ( &atadev->refcnt, NULL );
672 intf_init ( &atadev->block, &atadev_block_desc, &atadev->refcnt );
673 intf_init ( &atadev->ata, &atadev_ata_desc, &atadev->refcnt );
674 atadev->device = device;
675 atadev->max_count = max_count;
676
677 /* Attach to ATA and parent and interfaces, mortalise self,
678 * and return
679 */
680 intf_plug_plug ( &atadev->ata, ata );
681 intf_plug_plug ( &atadev->block, block );
682 ref_put ( &atadev->refcnt );
683 return 0;
684}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
static struct interface_descriptor atadev_ata_desc
ATA device ATA interface descriptor.
Definition ata.c:650
static struct interface_descriptor atadev_block_desc
ATA device block interface descriptor.
Definition ata.c:640
#define ENOMEM
Not enough space.
Definition errno.h:535
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition interface.c:108
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition interface.h:204
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:662
uint8_t block[3][8]
DES-encrypted blocks.
Definition mschapv2.h:1
#define ref_put(refcnt)
Drop reference to object.
Definition refcnt.h:107
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition refcnt.h:65
An ATA device.
Definition ata.c:90
unsigned int device
Device number.
Definition ata.c:102
struct refcnt refcnt
Reference count.
Definition ata.c:92
unsigned int max_count
Maximum number of blocks per single transfer.
Definition ata.c:104
struct interface ata
ATA control interface.
Definition ata.c:96
struct interface block
Block control interface.
Definition ata.c:94
A hardware device.
Definition device.h:77

References ata_device::ata, atadev_ata_desc, atadev_block_desc, ata_device::block, block, 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().