iPXE
Functions
blockdev.c File Reference

Block devices. More...

#include <errno.h>
#include <ipxe/interface.h>
#include <ipxe/blockdev.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
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.
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.
int block_read_capacity (struct interface *control, struct interface *data)
 Read block device capacity.
void block_capacity (struct interface *intf, struct block_device_capacity *capacity)
 Report block device capacity.

Detailed Description

Block devices.

Definition in file blockdev.c.


Function Documentation

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

Parameters:
controlControl interface
dataData interface
lbaStarting logical block address
countNumber of logical blocks
bufferData buffer
lenLength of data buffer
Return values:
rcReturn status code

Definition at line 47 of file blockdev.c.

References block_read(), block_read_TYPE, dest, EOPNOTSUPP, intf_get_dest_op, intf_object(), intf_put(), op, and rc.

Referenced by block_read(), and sandev_read().

                                                {
        struct interface *dest;
        block_read_TYPE ( void * ) *op =
                intf_get_dest_op ( control, block_read, &dest );
        void *object = intf_object ( dest );
        int rc;

        if ( op ) {
                rc = op ( object, data, lba, count, buffer, len );
        } else {
                /* Default is to fail to issue the command */
                rc = -EOPNOTSUPP;
        }

        intf_put ( dest );
        return rc;
}
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.

Parameters:
controlControl interface
dataData interface
lbaStarting logical block address
countNumber of logical blocks
bufferData buffer
lenLength of data buffer
Return values:
rcReturn status code

Definition at line 78 of file blockdev.c.

References block_write(), block_write_TYPE, dest, EOPNOTSUPP, intf_get_dest_op, intf_object(), intf_put(), op, and rc.

Referenced by block_write(), and sandev_write().

                                                 {
        struct interface *dest;
        block_write_TYPE ( void * ) *op =
                intf_get_dest_op ( control, block_write, &dest );
        void *object = intf_object ( dest );
        int rc;

        if ( op ) {
                rc = op ( object, data, lba, count, buffer, len );
        } else {
                /* Default is to fail to issue the command */
                rc = -EOPNOTSUPP;
        }

        intf_put ( dest );
        return rc;
}
int block_read_capacity ( struct interface control,
struct interface data 
)

Read block device capacity.

Parameters:
controlControl interface
dataData interface
Return values:
rcReturn status code

Definition at line 105 of file blockdev.c.

References block_read_capacity(), block_read_capacity_TYPE, dest, EOPNOTSUPP, intf_get_dest_op, intf_object(), intf_put(), op, and rc.

Referenced by block_read_capacity(), and sandev_command_read_capacity().

                                                                              {
        struct interface *dest;
        block_read_capacity_TYPE ( void * ) *op =
                intf_get_dest_op ( control, block_read_capacity, &dest );
        void *object = intf_object ( dest );
        int rc;

        if ( op ) {
                rc = op ( object, data );
        } else {
                /* Default is to fail to issue the command */
                rc = -EOPNOTSUPP;
        }

        intf_put ( dest );
        return rc;
}
void block_capacity ( struct interface intf,
struct block_device_capacity capacity 
)

Report block device capacity.

Parameters:
intfInterface
capacityBlock device capacity

Definition at line 129 of file blockdev.c.

References block_capacity(), block_capacity_TYPE, dest, intf_get_dest_op, intf_object(), intf_put(), and op.

Referenced by atacmd_identify_done(), blktrans_close(), block_capacity(), and scsicmd_read_capacity_done().

                                                               {
        struct interface *dest;
        block_capacity_TYPE ( void * ) *op =
                intf_get_dest_op ( intf, block_capacity, &dest );
        void *object = intf_object ( dest );

        if ( op ) {
                op ( object, capacity );
        } else {
                /* Default is to do nothing */
        }

        intf_put ( dest );
}