iPXE
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)
 FILE_SECBOOT (PERMITTED)
int block_read (struct interface *control, struct interface *data, uint64_t lba, unsigned int count, void *buffer, size_t len)
 Read from block device.
int block_write (struct interface *control, struct interface *data, uint64_t lba, unsigned int count, void *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()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ block_read()

int block_read ( struct interface * control,
struct interface * data,
uint64_t lba,
unsigned int count,
void * 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 48 of file blockdev.c.

50 {
51 struct interface *dest;
52 block_read_TYPE ( void * ) *op =
54 void *object = intf_object ( dest );
55 int rc;
56
57 if ( op ) {
58 rc = op ( object, data, lba, count, buffer, len );
59 } else {
60 /* Default is to fail to issue the command */
61 rc = -EOPNOTSUPP;
62 }
63
64 intf_put ( dest );
65 return rc;
66}
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
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
int block_read(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, void *buffer, size_t len)
Read from block device.
Definition blockdev.c:48
#define block_read_TYPE(object_type)
Definition blockdev.h:30
ring len
Length.
Definition dwmac.h:226
uint8_t data[48]
Additional event data.
Definition ena.h:11
static unsigned int count
Number of entries.
Definition dwmac.h:220
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition netvsc.h:5
uint64_t lba
Starting block number.
Definition int13.h:11
#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 object interface.
Definition interface.h:125

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,
void * 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 79 of file blockdev.c.

81 {
82 struct interface *dest;
83 block_write_TYPE ( void * ) *op =
85 void *object = intf_object ( dest );
86 int rc;
87
88 if ( op ) {
89 rc = op ( object, data, lba, count, buffer, len );
90 } else {
91 /* Default is to fail to issue the command */
92 rc = -EOPNOTSUPP;
93 }
94
95 intf_put ( dest );
96 return rc;
97}
int block_write(struct interface *control, struct interface *data, uint64_t lba, unsigned int count, void *buffer, size_t len)
Write to block device.
Definition blockdev.c:79
#define block_write_TYPE(object_type)
Definition blockdev.h:38

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 106 of file blockdev.c.

106 {
107 struct interface *dest;
108 block_read_capacity_TYPE ( void * ) *op =
110 void *object = intf_object ( dest );
111 int rc;
112
113 if ( op ) {
114 rc = op ( object, data );
115 } else {
116 /* Default is to fail to issue the command */
117 rc = -EOPNOTSUPP;
118 }
119
120 intf_put ( dest );
121 return rc;
122}
int block_read_capacity(struct interface *control, struct interface *data)
Read block device capacity.
Definition blockdev.c:106
#define block_read_capacity_TYPE(object_type)
Definition blockdev.h:45

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 130 of file blockdev.c.

131 {
132 struct interface *dest;
133 block_capacity_TYPE ( void * ) *op =
135 void *object = intf_object ( dest );
136
137 if ( op ) {
138 op ( object, capacity );
139 } else {
140 /* Default is to do nothing */
141 }
142
143 intf_put ( dest );
144}
void block_capacity(struct interface *intf, struct block_device_capacity *capacity)
Report block device capacity.
Definition blockdev.c:130
#define block_capacity_TYPE(object_type)
Definition blockdev.h:50
struct interface * intf
Original interface.
Definition interface.h:159

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

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