iPXE
Data Structures | Macros | Functions
ata.h File Reference

ATA devices. More...

#include <stdint.h>
#include <ipxe/uaccess.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. More...
 
#define ATA_DEV_LBA   0x40
 LBA flag in the ATA device register. More...
 
#define ATA_DEV_SLAVE   0x10
 Slave ("device 1") flag in the ATA device register. More...
 
#define ATA_DEV_MASTER   0x00
 Master ("device 0") flag in the ATA device register. More...
 
#define ATA_DEV_MASK   0xf0
 Mask of non-LBA portion of device register. More...
 
#define ATA_CMD_READ   0x20
 "Read sectors" command More...
 
#define ATA_CMD_READ_EXT   0x24
 "Read sectors (ext)" command More...
 
#define ATA_CMD_WRITE   0x30
 "Write sectors" command More...
 
#define ATA_CMD_WRITE_EXT   0x34
 "Write sectors (ext)" command More...
 
#define ATA_CMD_IDENTIFY   0xec
 "Identify" command More...
 
#define ATA_STAT_ERR   0x01
 Command completed in error. More...
 
#define ATA_SUPPORTS_LBA48   ( 1 << 10 )
 Supports LBA48 flag. More...
 
#define ATA_SECTOR_SIZE   512
 ATA sector size. More...
 
#define ata_command_TYPE(object_type)
 

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...
 
int ata_open (struct interface *block, struct interface *ata, unsigned int device, unsigned int max_count)
 Open ATA device. More...
 

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.

◆ ATA_DEV_LBA

#define ATA_DEV_LBA   0x40

LBA flag in the ATA device register.

Definition at line 114 of file ata.h.

◆ 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.

◆ 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.

◆ ATA_DEV_MASK

#define ATA_DEV_MASK   0xf0

Mask of non-LBA portion of device register.

Definition at line 123 of file ata.h.

◆ 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.

◆ ATA_SUPPORTS_LBA48

#define ATA_SUPPORTS_LBA48   ( 1 << 10 )

Supports LBA48 flag.

Definition at line 162 of file ata.h.

◆ ATA_SECTOR_SIZE

#define ATA_SECTOR_SIZE   512

ATA sector size.

Definition at line 165 of file ata.h.

◆ ata_command_TYPE

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

Definition at line 197 of file ata.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ ata_command()

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

Issue ATA command.

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

Definition at line 59 of file ata.c.

60  {
61  struct interface *dest;
62  ata_command_TYPE ( void * ) *op =
64  void *object = intf_object ( dest );
65  int tag;
66 
67  if ( op ) {
68  tag = op ( object, data, command );
69  } else {
70  /* Default is to fail to issue the command */
71  tag = -EOPNOTSUPP;
72  }
73 
74  intf_put ( dest );
75  return tag;
76 }
A command-line command.
Definition: command.h:9
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition: interface.c:159
An object interface.
Definition: interface.h:124
static void * dest
Definition: strings.h:176
uint32_t control
Control.
Definition: myson.h:14
#define EOPNOTSUPP
Operation not supported on socket.
Definition: errno.h:604
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
#define ata_command_TYPE(object_type)
Definition: ata.h:197
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition: interface.c:149
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint64_t tag
Identity tag.
Definition: edd.h:30
An ATA command.
Definition: ata.c:109
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:269

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 
)

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 662 of file ata.c.

663  {
664  struct ata_device *atadev;
665 
666  /* Allocate and initialise structure */
667  atadev = zalloc ( sizeof ( *atadev ) );
668  if ( ! atadev )
669  return -ENOMEM;
670  ref_init ( &atadev->refcnt, NULL );
671  intf_init ( &atadev->block, &atadev_block_desc, &atadev->refcnt );
672  intf_init ( &atadev->ata, &atadev_ata_desc, &atadev->refcnt );
673  atadev->device = device;
674  atadev->max_count = max_count;
675 
676  /* Attach to ATA and parent and interfaces, mortalise self,
677  * and return
678  */
679  intf_plug_plug ( &atadev->ata, ata );
680  intf_plug_plug ( &atadev->block, block );
681  ref_put ( &atadev->refcnt );
682  return 0;
683 }
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
Definition: interface.c:107
unsigned int device
Device number.
Definition: ata.c:101
uint16_t device
Device ID.
Definition: ena.h:24
static struct interface_descriptor atadev_block_desc
ATA device block interface descriptor.
Definition: ata.c:639
An ATA device.
Definition: ata.c:89
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct interface block
Block control interface.
Definition: ata.c:93
struct refcnt refcnt
Reference count.
Definition: ata.c:91
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
unsigned int max_count
Maximum number of blocks per single transfer.
Definition: ata.c:103
struct interface ata
ATA control interface.
Definition: ata.c:95
uint8_t block[3][8]
DES-encrypted blocks.
Definition: mschapv2.h:12
static struct interface_descriptor atadev_ata_desc
ATA device ATA interface descriptor.
Definition: ata.c:649
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:203
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

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().