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

Detailed Description

Block devices.

Definition in file blockdev.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ block_read()

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.

49  {
50  struct interface *dest;
51  block_read_TYPE ( void * ) *op =
53  void *object = intf_object ( dest );
54  int rc;
55 
56  if ( op ) {
57  rc = op ( object, data, lba, count, buffer, len );
58  } else {
59  /* Default is to fail to issue the command */
60  rc = -EOPNOTSUPP;
61  }
62 
63  intf_put ( dest );
64  return rc;
65 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t lba
Start address.
Definition: scsi.h:23
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.
Definition: blockdev.c:47
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition: interface.c:154
An object interface.
Definition: interface.h:109
#define block_read_TYPE(object_type)
Definition: blockdev.h:30
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
uint32_t len
Length.
Definition: ena.h:14
uint16_t count
Number of entries.
Definition: ena.h:22
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition: interface.c:144
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:214

References block_read(), block_read_TYPE, buffer, control, count, data, dest, EOPNOTSUPP, intf_get_dest_op, intf_object(), intf_put(), lba, len, op, and rc.

Referenced by block_read(), and sandev_read().

◆ block_write()

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.

80  {
81  struct interface *dest;
82  block_write_TYPE ( void * ) *op =
84  void *object = intf_object ( dest );
85  int rc;
86 
87  if ( op ) {
88  rc = op ( object, data, lba, count, buffer, len );
89  } else {
90  /* Default is to fail to issue the command */
91  rc = -EOPNOTSUPP;
92  }
93 
94  intf_put ( dest );
95  return rc;
96 }
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.
Definition: blockdev.c:78
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint32_t lba
Start address.
Definition: scsi.h:23
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition: interface.c:154
An object interface.
Definition: interface.h:109
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
#define block_write_TYPE(object_type)
Definition: blockdev.h:38
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
uint32_t len
Length.
Definition: ena.h:14
uint16_t count
Number of entries.
Definition: ena.h:22
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition: interface.c:144
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:214

References block_write(), block_write_TYPE, buffer, control, count, data, dest, EOPNOTSUPP, intf_get_dest_op, intf_object(), intf_put(), lba, len, op, and rc.

Referenced by block_write(), and sandev_write().

◆ block_read_capacity()

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.

105  {
106  struct interface *dest;
107  block_read_capacity_TYPE ( void * ) *op =
109  void *object = intf_object ( dest );
110  int rc;
111 
112  if ( op ) {
113  rc = op ( object, data );
114  } else {
115  /* Default is to fail to issue the command */
116  rc = -EOPNOTSUPP;
117  }
118 
119  intf_put ( dest );
120  return rc;
121 }
#define block_read_capacity_TYPE(object_type)
Definition: blockdev.h:45
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition: interface.c:154
An object interface.
Definition: interface.h:109
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
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition: interface.c:144
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12
int block_read_capacity(struct interface *control, struct interface *data)
Read block device capacity.
Definition: blockdev.c:105
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:214

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

Referenced by block_read_capacity(), and sandev_command_read_capacity().

◆ block_capacity()

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.

130  {
131  struct interface *dest;
132  block_capacity_TYPE ( void * ) *op =
134  void *object = intf_object ( dest );
135 
136  if ( op ) {
137  op ( object, capacity );
138  } else {
139  /* Default is to do nothing */
140  }
141 
142  intf_put ( dest );
143 }
void block_capacity(struct interface *intf, struct block_device_capacity *capacity)
Report block device capacity.
Definition: blockdev.c:129
void * intf_object(struct interface *intf)
Get pointer to object containing object interface.
Definition: interface.c:154
An object interface.
Definition: interface.h:109
static void * dest
Definition: strings.h:176
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
void intf_put(struct interface *intf)
Decrement reference count on an object interface.
Definition: interface.c:144
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:214
#define block_capacity_TYPE(object_type)
Definition: blockdev.h:50

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