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

Block devices. More...

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

Go to the source code of this file.

Data Structures

struct  block_device_capacity
 Block device capacity. More...
 

Macros

#define block_read_TYPE(object_type)
 
#define block_write_TYPE(object_type)
 
#define block_read_capacity_TYPE(object_type)   typeof ( int ( object_type, struct interface *data ) )
 
#define block_capacity_TYPE(object_type)
 

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

Macro Definition Documentation

◆ block_read_TYPE

#define block_read_TYPE (   object_type)
Value:
typeof ( int ( object_type, struct interface *data, \
uint64_t lba, unsigned int count, \
userptr_t buffer, size_t len ) )
unsigned long long uint64_t
Definition: stdint.h:13
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
uint32_t userptr_t
A pointer to a user buffer.
Definition: libkir.h:159
An object interface.
Definition: interface.h:124
uint16_t count
Number of entries.
Definition: ena.h:22
uint64_t lba
Starting block number.
Definition: int13.h:22
uint8_t data[48]
Additional event data.
Definition: ena.h:22
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45
uint32_t len
Length.
Definition: ena.h:14

Definition at line 30 of file blockdev.h.

◆ block_write_TYPE

#define block_write_TYPE (   object_type)
Value:
typeof ( int ( object_type, struct interface *data, \
uint64_t lba, unsigned int count, \
userptr_t buffer, size_t len ) )
unsigned long long uint64_t
Definition: stdint.h:13
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
uint32_t userptr_t
A pointer to a user buffer.
Definition: libkir.h:159
An object interface.
Definition: interface.h:124
uint16_t count
Number of entries.
Definition: ena.h:22
uint64_t lba
Starting block number.
Definition: int13.h:22
uint8_t data[48]
Additional event data.
Definition: ena.h:22
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45
uint32_t len
Length.
Definition: ena.h:14

Definition at line 38 of file blockdev.h.

◆ block_read_capacity_TYPE

#define block_read_capacity_TYPE (   object_type)    typeof ( int ( object_type, struct interface *data ) )

Definition at line 45 of file blockdev.h.

◆ block_capacity_TYPE

#define block_capacity_TYPE (   object_type)
Value:
typeof ( void ( object_type, \
struct block_device_capacity *capacity ) )
Block device capacity.
Definition: blockdev.h:18
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition: acpi.c:45

Definition at line 50 of file blockdev.h.

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
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:159
An object interface.
Definition: interface.h:124
#define block_read_TYPE(object_type)
Definition: blockdev.h:30
uint16_t count
Number of entries.
Definition: ena.h:22
uint32_t control
Control.
Definition: myson.h:14
#define EOPNOTSUPP
Operation not supported on socket.
Definition: errno.h:604
uint64_t lba
Starting block number.
Definition: int13.h:22
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:149
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" return dest
Definition: string.h:150
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint32_t len
Length.
Definition: ena.h:14
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:269

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 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:159
An object interface.
Definition: interface.h:124
uint16_t count
Number of entries.
Definition: ena.h:22
uint32_t control
Control.
Definition: myson.h:14
#define EOPNOTSUPP
Operation not supported on socket.
Definition: errno.h:604
uint64_t lba
Starting block number.
Definition: int13.h:22
#define block_write_TYPE(object_type)
Definition: blockdev.h:38
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:149
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" return dest
Definition: string.h:150
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint32_t len
Length.
Definition: ena.h:14
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:269

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:159
An object interface.
Definition: interface.h:124
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:149
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" return dest
Definition: string.h:150
uint8_t data[48]
Additional event data.
Definition: ena.h:22
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:269

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:159
struct interface * intf
Original interface.
Definition: interface.h:158
An object interface.
Definition: interface.h:124
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:149
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" return dest
Definition: string.h:150
#define intf_get_dest_op(intf, type, dest)
Get object interface destination and operation method.
Definition: interface.h:269
#define block_capacity_TYPE(object_type)
Definition: blockdev.h:50

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