mirror of
https://github.com/ipxe/ipxe
synced 2025-12-22 21:11:03 +03:00
[block] Remove userptr_t from block device abstraction
Simplify the block device code by assuming that all read/write buffers are directly accessible via pointer dereferences. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -181,8 +181,7 @@ static int int13_parse_eltorito ( struct san_device *sandev, void *scratch ) {
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Read boot record volume descriptor */
|
/* Read boot record volume descriptor */
|
||||||
if ( ( rc = sandev_read ( sandev, ELTORITO_LBA, 1,
|
if ( ( rc = sandev_read ( sandev, ELTORITO_LBA, 1, boot ) ) != 0 ) {
|
||||||
virt_to_user ( boot ) ) ) != 0 ) {
|
|
||||||
DBGC ( sandev->drive, "INT13 drive %02x could not read El "
|
DBGC ( sandev->drive, "INT13 drive %02x could not read El "
|
||||||
"Torito boot record volume descriptor: %s\n",
|
"Torito boot record volume descriptor: %s\n",
|
||||||
sandev->drive, strerror ( rc ) );
|
sandev->drive, strerror ( rc ) );
|
||||||
@@ -228,7 +227,7 @@ static int int13_guess_geometry_hdd ( struct san_device *sandev, void *scratch,
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Read partition table */
|
/* Read partition table */
|
||||||
if ( ( rc = sandev_read ( sandev, 0, 1, virt_to_user ( mbr ) ) ) != 0 ) {
|
if ( ( rc = sandev_read ( sandev, 0, 1, mbr ) ) != 0 ) {
|
||||||
DBGC ( sandev->drive, "INT13 drive %02x could not read "
|
DBGC ( sandev->drive, "INT13 drive %02x could not read "
|
||||||
"partition table to guess geometry: %s\n",
|
"partition table to guess geometry: %s\n",
|
||||||
sandev->drive, strerror ( rc ) );
|
sandev->drive, strerror ( rc ) );
|
||||||
@@ -517,12 +516,12 @@ static int int13_rw_sectors ( struct san_device *sandev,
|
|||||||
int ( * sandev_rw ) ( struct san_device *sandev,
|
int ( * sandev_rw ) ( struct san_device *sandev,
|
||||||
uint64_t lba,
|
uint64_t lba,
|
||||||
unsigned int count,
|
unsigned int count,
|
||||||
userptr_t buffer ) ) {
|
void *buffer ) ) {
|
||||||
struct int13_data *int13 = sandev->priv;
|
struct int13_data *int13 = sandev->priv;
|
||||||
unsigned int cylinder, head, sector;
|
unsigned int cylinder, head, sector;
|
||||||
unsigned long lba;
|
unsigned long lba;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
userptr_t buffer;
|
void *buffer;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Validate blocksize */
|
/* Validate blocksize */
|
||||||
@@ -710,12 +709,12 @@ static int int13_extended_rw ( struct san_device *sandev,
|
|||||||
int ( * sandev_rw ) ( struct san_device *sandev,
|
int ( * sandev_rw ) ( struct san_device *sandev,
|
||||||
uint64_t lba,
|
uint64_t lba,
|
||||||
unsigned int count,
|
unsigned int count,
|
||||||
userptr_t buffer ) ) {
|
void *buffer ) ) {
|
||||||
struct int13_disk_address addr;
|
struct int13_disk_address addr;
|
||||||
uint8_t bufsize;
|
uint8_t bufsize;
|
||||||
uint64_t lba;
|
uint64_t lba;
|
||||||
unsigned long count;
|
unsigned long count;
|
||||||
userptr_t buffer;
|
void *buffer;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Extended reads are not allowed on floppy drives.
|
/* Extended reads are not allowed on floppy drives.
|
||||||
@@ -1455,8 +1454,8 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) {
|
|||||||
"catalog (status %04x)\n", drive, status );
|
"catalog (status %04x)\n", drive, status );
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
copy_from_user ( &catalog, phys_to_virt ( eltorito_cmd.buffer ), 0,
|
memcpy ( &catalog, phys_to_virt ( eltorito_cmd.buffer ),
|
||||||
sizeof ( catalog ) );
|
sizeof ( catalog ) );
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
if ( catalog.valid.platform_id != ELTORITO_PLATFORM_X86 ) {
|
if ( catalog.valid.platform_id != ELTORITO_PLATFORM_X86 ) {
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int block_read ( struct interface *control, struct interface *data,
|
int block_read ( struct interface *control, struct interface *data,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba, unsigned int count, void *buffer,
|
||||||
userptr_t buffer, size_t len ) {
|
size_t len ) {
|
||||||
struct interface *dest;
|
struct interface *dest;
|
||||||
block_read_TYPE ( void * ) *op =
|
block_read_TYPE ( void * ) *op =
|
||||||
intf_get_dest_op ( control, block_read, &dest );
|
intf_get_dest_op ( control, block_read, &dest );
|
||||||
@@ -76,8 +76,8 @@ int block_read ( struct interface *control, struct interface *data,
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int block_write ( struct interface *control, struct interface *data,
|
int block_write ( struct interface *control, struct interface *data,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba, unsigned int count, void *buffer,
|
||||||
userptr_t buffer, size_t len ) {
|
size_t len ) {
|
||||||
struct interface *dest;
|
struct interface *dest;
|
||||||
block_write_TYPE ( void * ) *op =
|
block_write_TYPE ( void * ) *op =
|
||||||
intf_get_dest_op ( control, block_write, &dest );
|
intf_get_dest_op ( control, block_write, &dest );
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ static void blktrans_xferbuf_write ( struct xfer_buffer *xferbuf, size_t offset,
|
|||||||
if ( blktrans->buffer ) {
|
if ( blktrans->buffer ) {
|
||||||
|
|
||||||
/* Write data to buffer */
|
/* Write data to buffer */
|
||||||
copy_to_user ( blktrans->buffer, offset, data, len );
|
memcpy ( ( blktrans->buffer + offset ), data, len );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ static void blktrans_xferbuf_read ( struct xfer_buffer *xferbuf, size_t offset,
|
|||||||
if ( blktrans->buffer ) {
|
if ( blktrans->buffer ) {
|
||||||
|
|
||||||
/* Read data from buffer */
|
/* Read data from buffer */
|
||||||
copy_from_user ( data, blktrans->buffer, offset, len );
|
memcpy ( data, ( blktrans->buffer + offset ), len );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -216,11 +216,11 @@ static struct interface_descriptor blktrans_xfer_desc =
|
|||||||
* Insert block device translator
|
* Insert block device translator
|
||||||
*
|
*
|
||||||
* @v block Block device interface
|
* @v block Block device interface
|
||||||
* @v buffer Data buffer (or UNULL)
|
* @v buffer Data buffer (or NULL)
|
||||||
* @v size Length of data buffer, or block size
|
* @v size Length of data buffer, or block size
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int block_translate ( struct interface *block, userptr_t buffer, size_t size ) {
|
int block_translate ( struct interface *block, void *buffer, size_t size ) {
|
||||||
struct block_translator *blktrans;
|
struct block_translator *blktrans;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ipxe/sanboot.h>
|
#include <ipxe/sanboot.h>
|
||||||
|
|
||||||
|
|||||||
@@ -424,10 +424,10 @@ int sandev_reopen ( struct san_device *sandev ) {
|
|||||||
struct san_command_rw_params {
|
struct san_command_rw_params {
|
||||||
/** SAN device read/write operation */
|
/** SAN device read/write operation */
|
||||||
int ( * block_rw ) ( struct interface *control, struct interface *data,
|
int ( * block_rw ) ( struct interface *control, struct interface *data,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba, unsigned int count, void *buffer,
|
||||||
userptr_t buffer, size_t len );
|
size_t len );
|
||||||
/** Data buffer */
|
/** Data buffer */
|
||||||
userptr_t buffer;
|
void *buffer;
|
||||||
/** Starting LBA */
|
/** Starting LBA */
|
||||||
uint64_t lba;
|
uint64_t lba;
|
||||||
/** Block count */
|
/** Block count */
|
||||||
@@ -594,11 +594,11 @@ int sandev_reset ( struct san_device *sandev ) {
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static int sandev_rw ( struct san_device *sandev, uint64_t lba,
|
static int sandev_rw ( struct san_device *sandev, uint64_t lba,
|
||||||
unsigned int count, userptr_t buffer,
|
unsigned int count, void *buffer,
|
||||||
int ( * block_rw ) ( struct interface *control,
|
int ( * block_rw ) ( struct interface *control,
|
||||||
struct interface *data,
|
struct interface *data,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba, unsigned int count,
|
||||||
userptr_t buffer, size_t len ) ) {
|
void *buffer, size_t len ) ) {
|
||||||
union san_command_params params;
|
union san_command_params params;
|
||||||
unsigned int remaining;
|
unsigned int remaining;
|
||||||
size_t frag_len;
|
size_t frag_len;
|
||||||
@@ -643,11 +643,12 @@ static int sandev_rw ( struct san_device *sandev, uint64_t lba,
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int sandev_read ( struct san_device *sandev, uint64_t lba,
|
int sandev_read ( struct san_device *sandev, uint64_t lba,
|
||||||
unsigned int count, userptr_t buffer ) {
|
unsigned int count, void *buffer ) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Read from device */
|
/* Read from device */
|
||||||
if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_read ) ) != 0 )
|
if ( ( rc = sandev_rw ( sandev, lba, count, buffer,
|
||||||
|
block_read ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -663,11 +664,12 @@ int sandev_read ( struct san_device *sandev, uint64_t lba,
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int sandev_write ( struct san_device *sandev, uint64_t lba,
|
int sandev_write ( struct san_device *sandev, uint64_t lba,
|
||||||
unsigned int count, userptr_t buffer ) {
|
unsigned int count, void *buffer ) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Write to device */
|
/* Write to device */
|
||||||
if ( ( rc = sandev_rw ( sandev, lba, count, buffer, block_write ) ) != 0 )
|
if ( ( rc = sandev_rw ( sandev, lba, count, buffer,
|
||||||
|
block_write ) ) != 0 )
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
/* Quiesce system. This is a heuristic designed to ensure
|
/* Quiesce system. This is a heuristic designed to ensure
|
||||||
@@ -799,8 +801,7 @@ static int sandev_parse_iso9660 ( struct san_device *sandev ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read primary volume descriptor */
|
/* Read primary volume descriptor */
|
||||||
if ( ( rc = sandev_read ( sandev, lba, count,
|
if ( ( rc = sandev_read ( sandev, lba, count, scratch ) ) != 0 ) {
|
||||||
virt_to_user ( scratch ) ) ) != 0 ) {
|
|
||||||
DBGC ( sandev->drive, "SAN %#02x could not read ISO9660 "
|
DBGC ( sandev->drive, "SAN %#02x could not read ISO9660 "
|
||||||
"primary volume descriptor: %s\n",
|
"primary volume descriptor: %s\n",
|
||||||
sandev->drive, strerror ( rc ) );
|
sandev->drive, strerror ( rc ) );
|
||||||
|
|||||||
@@ -147,8 +147,8 @@ struct ata_command_type {
|
|||||||
* @ret data_in Data-in buffer
|
* @ret data_in Data-in buffer
|
||||||
* @ret data_in_len Data-in buffer length
|
* @ret data_in_len Data-in buffer length
|
||||||
*/
|
*/
|
||||||
void ( * data_in ) ( struct ata_command *atacmd, userptr_t buffer,
|
void ( * data_in ) ( struct ata_command *atacmd, void *buffer,
|
||||||
size_t len, userptr_t *data_in,
|
size_t len, void **data_in,
|
||||||
size_t *data_in_len );
|
size_t *data_in_len );
|
||||||
/**
|
/**
|
||||||
* Calculate data-out buffer
|
* Calculate data-out buffer
|
||||||
@@ -160,8 +160,8 @@ struct ata_command_type {
|
|||||||
* @ret data_out Data-out buffer
|
* @ret data_out Data-out buffer
|
||||||
* @ret data_out_len Data-out buffer length
|
* @ret data_out_len Data-out buffer length
|
||||||
*/
|
*/
|
||||||
void ( * data_out ) ( struct ata_command *atacmd, userptr_t buffer,
|
void ( * data_out ) ( struct ata_command *atacmd, void *buffer,
|
||||||
size_t len, userptr_t *data_out,
|
size_t len, void **data_out,
|
||||||
size_t *data_out_len );
|
size_t *data_out_len );
|
||||||
/**
|
/**
|
||||||
* Handle ATA command completion
|
* Handle ATA command completion
|
||||||
@@ -285,8 +285,8 @@ static void atacmd_done ( struct ata_command *atacmd, int rc ) {
|
|||||||
* @ret data_len Data buffer length
|
* @ret data_len Data buffer length
|
||||||
*/
|
*/
|
||||||
static void atacmd_data_buffer ( struct ata_command *atacmd __unused,
|
static void atacmd_data_buffer ( struct ata_command *atacmd __unused,
|
||||||
userptr_t buffer, size_t len,
|
void *buffer, size_t len,
|
||||||
userptr_t *data, size_t *data_len ) {
|
void **data, size_t *data_len ) {
|
||||||
*data = buffer;
|
*data = buffer;
|
||||||
*data_len = len;
|
*data_len = len;
|
||||||
}
|
}
|
||||||
@@ -301,8 +301,8 @@ static void atacmd_data_buffer ( struct ata_command *atacmd __unused,
|
|||||||
* @ret data_len Data buffer length
|
* @ret data_len Data buffer length
|
||||||
*/
|
*/
|
||||||
static void atacmd_data_none ( struct ata_command *atacmd __unused,
|
static void atacmd_data_none ( struct ata_command *atacmd __unused,
|
||||||
userptr_t buffer __unused, size_t len __unused,
|
void *buffer __unused, size_t len __unused,
|
||||||
userptr_t *data __unused,
|
void **data __unused,
|
||||||
size_t *data_len __unused ) {
|
size_t *data_len __unused ) {
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
}
|
}
|
||||||
@@ -317,9 +317,9 @@ static void atacmd_data_none ( struct ata_command *atacmd __unused,
|
|||||||
* @ret data_len Data buffer length
|
* @ret data_len Data buffer length
|
||||||
*/
|
*/
|
||||||
static void atacmd_data_priv ( struct ata_command *atacmd,
|
static void atacmd_data_priv ( struct ata_command *atacmd,
|
||||||
userptr_t buffer __unused, size_t len __unused,
|
void *buffer __unused, size_t len __unused,
|
||||||
userptr_t *data, size_t *data_len ) {
|
void **data, size_t *data_len ) {
|
||||||
*data = virt_to_user ( atacmd_priv ( atacmd ) );
|
*data = atacmd_priv ( atacmd );
|
||||||
*data_len = atacmd->type->priv_len;
|
*data_len = atacmd->type->priv_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,7 +455,7 @@ static int atadev_command ( struct ata_device *atadev,
|
|||||||
struct interface *block,
|
struct interface *block,
|
||||||
struct ata_command_type *type,
|
struct ata_command_type *type,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba, unsigned int count,
|
||||||
userptr_t buffer, size_t len ) {
|
void *buffer, size_t len ) {
|
||||||
struct ata_command *atacmd;
|
struct ata_command *atacmd;
|
||||||
struct ata_cmd command;
|
struct ata_cmd command;
|
||||||
int tag;
|
int tag;
|
||||||
@@ -543,7 +543,7 @@ static int atadev_command ( struct ata_device *atadev,
|
|||||||
static int atadev_read ( struct ata_device *atadev,
|
static int atadev_read ( struct ata_device *atadev,
|
||||||
struct interface *block,
|
struct interface *block,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba, unsigned int count,
|
||||||
userptr_t buffer, size_t len ) {
|
void *buffer, size_t len ) {
|
||||||
return atadev_command ( atadev, block, &atacmd_read,
|
return atadev_command ( atadev, block, &atacmd_read,
|
||||||
lba, count, buffer, len );
|
lba, count, buffer, len );
|
||||||
}
|
}
|
||||||
@@ -562,7 +562,7 @@ static int atadev_read ( struct ata_device *atadev,
|
|||||||
static int atadev_write ( struct ata_device *atadev,
|
static int atadev_write ( struct ata_device *atadev,
|
||||||
struct interface *block,
|
struct interface *block,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba, unsigned int count,
|
||||||
userptr_t buffer, size_t len ) {
|
void *buffer, size_t len ) {
|
||||||
return atadev_command ( atadev, block, &atacmd_write,
|
return atadev_command ( atadev, block, &atacmd_write,
|
||||||
lba, count, buffer, len );
|
lba, count, buffer, len );
|
||||||
}
|
}
|
||||||
@@ -581,7 +581,7 @@ static int atadev_read_capacity ( struct ata_device *atadev,
|
|||||||
assert ( atacmd_identify.priv_len == sizeof ( *identity ) );
|
assert ( atacmd_identify.priv_len == sizeof ( *identity ) );
|
||||||
assert ( atacmd_identify.priv_len == ATA_SECTOR_SIZE );
|
assert ( atacmd_identify.priv_len == ATA_SECTOR_SIZE );
|
||||||
return atadev_command ( atadev, block, &atacmd_identify,
|
return atadev_command ( atadev, block, &atacmd_identify,
|
||||||
0, 1, UNULL, ATA_SECTOR_SIZE );
|
0, 1, NULL, ATA_SECTOR_SIZE );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ struct scsi_command {
|
|||||||
/** Number of blocks */
|
/** Number of blocks */
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
/** Data buffer */
|
/** Data buffer */
|
||||||
userptr_t buffer;
|
void *buffer;
|
||||||
/** Length of data buffer */
|
/** Length of data buffer */
|
||||||
size_t len;
|
size_t len;
|
||||||
/** Command tag */
|
/** Command tag */
|
||||||
@@ -591,12 +591,12 @@ static void scsicmd_read_capacity_cmd ( struct scsi_command *scsicmd,
|
|||||||
readcap16->service_action =
|
readcap16->service_action =
|
||||||
SCSI_SERVICE_ACTION_READ_CAPACITY_16;
|
SCSI_SERVICE_ACTION_READ_CAPACITY_16;
|
||||||
readcap16->len = cpu_to_be32 ( sizeof ( *capacity16 ) );
|
readcap16->len = cpu_to_be32 ( sizeof ( *capacity16 ) );
|
||||||
command->data_in = virt_to_user ( capacity16 );
|
command->data_in = capacity16;
|
||||||
command->data_in_len = sizeof ( *capacity16 );
|
command->data_in_len = sizeof ( *capacity16 );
|
||||||
} else {
|
} else {
|
||||||
/* Use READ CAPACITY (10) */
|
/* Use READ CAPACITY (10) */
|
||||||
readcap10->opcode = SCSI_OPCODE_READ_CAPACITY_10;
|
readcap10->opcode = SCSI_OPCODE_READ_CAPACITY_10;
|
||||||
command->data_in = virt_to_user ( capacity10 );
|
command->data_in = capacity10;
|
||||||
command->data_in_len = sizeof ( *capacity10 );
|
command->data_in_len = sizeof ( *capacity10 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -721,7 +721,7 @@ static int scsidev_command ( struct scsi_device *scsidev,
|
|||||||
struct interface *block,
|
struct interface *block,
|
||||||
struct scsi_command_type *type,
|
struct scsi_command_type *type,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba, unsigned int count,
|
||||||
userptr_t buffer, size_t len ) {
|
void *buffer, size_t len ) {
|
||||||
struct scsi_command *scsicmd;
|
struct scsi_command *scsicmd;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@@ -773,7 +773,7 @@ static int scsidev_command ( struct scsi_device *scsidev,
|
|||||||
static int scsidev_read ( struct scsi_device *scsidev,
|
static int scsidev_read ( struct scsi_device *scsidev,
|
||||||
struct interface *block,
|
struct interface *block,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba, unsigned int count,
|
||||||
userptr_t buffer, size_t len ) {
|
void *buffer, size_t len ) {
|
||||||
return scsidev_command ( scsidev, block, &scsicmd_read,
|
return scsidev_command ( scsidev, block, &scsicmd_read,
|
||||||
lba, count, buffer, len );
|
lba, count, buffer, len );
|
||||||
}
|
}
|
||||||
@@ -792,7 +792,7 @@ static int scsidev_read ( struct scsi_device *scsidev,
|
|||||||
static int scsidev_write ( struct scsi_device *scsidev,
|
static int scsidev_write ( struct scsi_device *scsidev,
|
||||||
struct interface *block,
|
struct interface *block,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba, unsigned int count,
|
||||||
userptr_t buffer, size_t len ) {
|
void *buffer, size_t len ) {
|
||||||
return scsidev_command ( scsidev, block, &scsicmd_write,
|
return scsidev_command ( scsidev, block, &scsicmd_write,
|
||||||
lba, count, buffer, len );
|
lba, count, buffer, len );
|
||||||
}
|
}
|
||||||
@@ -807,7 +807,7 @@ static int scsidev_write ( struct scsi_device *scsidev,
|
|||||||
static int scsidev_read_capacity ( struct scsi_device *scsidev,
|
static int scsidev_read_capacity ( struct scsi_device *scsidev,
|
||||||
struct interface *block ) {
|
struct interface *block ) {
|
||||||
return scsidev_command ( scsidev, block, &scsicmd_read_capacity,
|
return scsidev_command ( scsidev, block, &scsicmd_read_capacity,
|
||||||
0, 0, UNULL, 0 );
|
0, 0, NULL, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -820,7 +820,7 @@ static int scsidev_read_capacity ( struct scsi_device *scsidev,
|
|||||||
static int scsidev_test_unit_ready ( struct scsi_device *scsidev,
|
static int scsidev_test_unit_ready ( struct scsi_device *scsidev,
|
||||||
struct interface *block ) {
|
struct interface *block ) {
|
||||||
return scsidev_command ( scsidev, block, &scsicmd_test_unit_ready,
|
return scsidev_command ( scsidev, block, &scsicmd_test_unit_ready,
|
||||||
0, 0, UNULL, 0 );
|
0, 0, NULL, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ static int usbblk_out_data ( struct usbblk_device *usbblk ) {
|
|||||||
|
|
||||||
/* Calculate length */
|
/* Calculate length */
|
||||||
assert ( cmd->tag );
|
assert ( cmd->tag );
|
||||||
assert ( cmd->scsi.data_out != UNULL );
|
assert ( cmd->scsi.data_out != NULL );
|
||||||
assert ( cmd->offset < cmd->scsi.data_out_len );
|
assert ( cmd->offset < cmd->scsi.data_out_len );
|
||||||
len = ( cmd->scsi.data_out_len - cmd->offset );
|
len = ( cmd->scsi.data_out_len - cmd->offset );
|
||||||
if ( len > USBBLK_MAX_LEN )
|
if ( len > USBBLK_MAX_LEN )
|
||||||
@@ -220,8 +220,8 @@ static int usbblk_out_data ( struct usbblk_device *usbblk ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Populate I/O buffer */
|
/* Populate I/O buffer */
|
||||||
copy_from_user ( iob_put ( iobuf, len ), cmd->scsi.data_out,
|
memcpy ( iob_put ( iobuf, len ),
|
||||||
cmd->offset, len );
|
( cmd->scsi.data_out + cmd->offset ), len );
|
||||||
|
|
||||||
/* Send data */
|
/* Send data */
|
||||||
if ( ( rc = usb_stream ( &usbblk->out, iobuf, 0 ) ) != 0 ) {
|
if ( ( rc = usb_stream ( &usbblk->out, iobuf, 0 ) ) != 0 ) {
|
||||||
@@ -332,12 +332,12 @@ static int usbblk_in_data ( struct usbblk_device *usbblk, const void *data,
|
|||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
assert ( cmd->tag );
|
assert ( cmd->tag );
|
||||||
assert ( cmd->scsi.data_in != UNULL );
|
assert ( cmd->scsi.data_in != NULL );
|
||||||
assert ( cmd->offset <= cmd->scsi.data_in_len );
|
assert ( cmd->offset <= cmd->scsi.data_in_len );
|
||||||
assert ( len <= ( cmd->scsi.data_in_len - cmd->offset ) );
|
assert ( len <= ( cmd->scsi.data_in_len - cmd->offset ) );
|
||||||
|
|
||||||
/* Store data */
|
/* Store data */
|
||||||
copy_to_user ( cmd->scsi.data_in, cmd->offset, data, len );
|
memcpy ( ( cmd->scsi.data_in + cmd->offset ), data, len );
|
||||||
cmd->offset += len;
|
cmd->offset += len;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#define _IPXE_ATA_H
|
#define _IPXE_ATA_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <ipxe/uaccess.h>
|
|
||||||
#include <ipxe/interface.h>
|
#include <ipxe/interface.h>
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
@@ -173,7 +172,7 @@ struct ata_cmd {
|
|||||||
* If non-NULL, this buffer must be ata_command::cb::count
|
* If non-NULL, this buffer must be ata_command::cb::count
|
||||||
* sectors in size.
|
* sectors in size.
|
||||||
*/
|
*/
|
||||||
userptr_t data_out;
|
void *data_out;
|
||||||
/** Data-out buffer length
|
/** Data-out buffer length
|
||||||
*
|
*
|
||||||
* Must be zero if @c data_out is NULL
|
* Must be zero if @c data_out is NULL
|
||||||
@@ -184,7 +183,7 @@ struct ata_cmd {
|
|||||||
* If non-NULL, this buffer must be ata_command::cb::count
|
* If non-NULL, this buffer must be ata_command::cb::count
|
||||||
* sectors in size.
|
* sectors in size.
|
||||||
*/
|
*/
|
||||||
userptr_t data_in;
|
void *data_in;
|
||||||
/** Data-in buffer length
|
/** Data-in buffer length
|
||||||
*
|
*
|
||||||
* Must be zero if @c data_in is NULL
|
* Must be zero if @c data_in is NULL
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <ipxe/uaccess.h>
|
|
||||||
#include <ipxe/interface.h>
|
#include <ipxe/interface.h>
|
||||||
|
|
||||||
/** Block device capacity */
|
/** Block device capacity */
|
||||||
@@ -25,20 +24,20 @@ struct block_device_capacity {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern int block_read ( struct interface *control, struct interface *data,
|
extern int block_read ( struct interface *control, struct interface *data,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba, unsigned int count, void *buffer,
|
||||||
userptr_t buffer, size_t len );
|
size_t len );
|
||||||
#define block_read_TYPE( object_type ) \
|
#define block_read_TYPE( object_type ) \
|
||||||
typeof ( int ( object_type, struct interface *data, \
|
typeof ( int ( object_type, struct interface *data, \
|
||||||
uint64_t lba, unsigned int count, \
|
uint64_t lba, unsigned int count, \
|
||||||
userptr_t buffer, size_t len ) )
|
void *buffer, size_t len ) )
|
||||||
|
|
||||||
extern int block_write ( struct interface *control, struct interface *data,
|
extern int block_write ( struct interface *control, struct interface *data,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba, unsigned int count, void *buffer,
|
||||||
userptr_t buffer, size_t len );
|
size_t len );
|
||||||
#define block_write_TYPE( object_type ) \
|
#define block_write_TYPE( object_type ) \
|
||||||
typeof ( int ( object_type, struct interface *data, \
|
typeof ( int ( object_type, struct interface *data, \
|
||||||
uint64_t lba, unsigned int count, \
|
uint64_t lba, unsigned int count, \
|
||||||
userptr_t buffer, size_t len ) )
|
void *buffer, size_t len ) )
|
||||||
|
|
||||||
extern int block_read_capacity ( struct interface *control,
|
extern int block_read_capacity ( struct interface *control,
|
||||||
struct interface *data );
|
struct interface *data );
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#include <ipxe/refcnt.h>
|
#include <ipxe/refcnt.h>
|
||||||
#include <ipxe/interface.h>
|
#include <ipxe/interface.h>
|
||||||
#include <ipxe/xferbuf.h>
|
#include <ipxe/xferbuf.h>
|
||||||
#include <ipxe/uaccess.h>
|
|
||||||
|
|
||||||
/** A block device translator */
|
/** A block device translator */
|
||||||
struct block_translator {
|
struct block_translator {
|
||||||
@@ -27,12 +26,12 @@ struct block_translator {
|
|||||||
/** Data transfer buffer */
|
/** Data transfer buffer */
|
||||||
struct xfer_buffer xferbuf;
|
struct xfer_buffer xferbuf;
|
||||||
/** Data buffer */
|
/** Data buffer */
|
||||||
userptr_t buffer;
|
void *buffer;
|
||||||
/** Block size */
|
/** Block size */
|
||||||
size_t blksize;
|
size_t blksize;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int block_translate ( struct interface *block,
|
extern int block_translate ( struct interface *block, void *buffer,
|
||||||
userptr_t buffer, size_t size );
|
size_t size );
|
||||||
|
|
||||||
#endif /* _IPXE_BLOCKTRANS_H */
|
#endif /* _IPXE_BLOCKTRANS_H */
|
||||||
|
|||||||
@@ -261,9 +261,9 @@ extern struct san_device * sandev_next ( unsigned int drive );
|
|||||||
extern int sandev_reopen ( struct san_device *sandev );
|
extern int sandev_reopen ( struct san_device *sandev );
|
||||||
extern int sandev_reset ( struct san_device *sandev );
|
extern int sandev_reset ( struct san_device *sandev );
|
||||||
extern int sandev_read ( struct san_device *sandev, uint64_t lba,
|
extern int sandev_read ( struct san_device *sandev, uint64_t lba,
|
||||||
unsigned int count, userptr_t buffer );
|
unsigned int count, void *buffer );
|
||||||
extern int sandev_write ( struct san_device *sandev, uint64_t lba,
|
extern int sandev_write ( struct san_device *sandev, uint64_t lba,
|
||||||
unsigned int count, userptr_t buffer );
|
unsigned int count, void *buffer );
|
||||||
extern struct san_device * alloc_sandev ( struct uri **uris, unsigned int count,
|
extern struct san_device * alloc_sandev ( struct uri **uris, unsigned int count,
|
||||||
size_t priv_size );
|
size_t priv_size );
|
||||||
extern int register_sandev ( struct san_device *sandev, unsigned int drive,
|
extern int register_sandev ( struct san_device *sandev, unsigned int drive,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#define _IPXE_SCSI_H
|
#define _IPXE_SCSI_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <ipxe/uaccess.h>
|
|
||||||
#include <ipxe/interface.h>
|
#include <ipxe/interface.h>
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
@@ -252,14 +251,14 @@ struct scsi_cmd {
|
|||||||
/** CDB for this command */
|
/** CDB for this command */
|
||||||
union scsi_cdb cdb;
|
union scsi_cdb cdb;
|
||||||
/** Data-out buffer (may be NULL) */
|
/** Data-out buffer (may be NULL) */
|
||||||
userptr_t data_out;
|
void *data_out;
|
||||||
/** Data-out buffer length
|
/** Data-out buffer length
|
||||||
*
|
*
|
||||||
* Must be zero if @c data_out is NULL
|
* Must be zero if @c data_out is NULL
|
||||||
*/
|
*/
|
||||||
size_t data_out_len;
|
size_t data_out_len;
|
||||||
/** Data-in buffer (may be NULL) */
|
/** Data-in buffer (may be NULL) */
|
||||||
userptr_t data_in;
|
void *data_in;
|
||||||
/** Data-in buffer length
|
/** Data-in buffer length
|
||||||
*
|
*
|
||||||
* Must be zero if @c data_in is NULL
|
* Must be zero if @c data_in is NULL
|
||||||
|
|||||||
@@ -95,8 +95,9 @@ struct efi_block_data {
|
|||||||
static int efi_block_rw ( struct san_device *sandev, uint64_t lba,
|
static int efi_block_rw ( struct san_device *sandev, uint64_t lba,
|
||||||
void *data, size_t len,
|
void *data, size_t len,
|
||||||
int ( * sandev_rw ) ( struct san_device *sandev,
|
int ( * sandev_rw ) ( struct san_device *sandev,
|
||||||
uint64_t lba, unsigned int count,
|
uint64_t lba,
|
||||||
userptr_t buffer ) ) {
|
unsigned int count,
|
||||||
|
void *buffer ) ) {
|
||||||
struct efi_block_data *block = sandev->priv;
|
struct efi_block_data *block = sandev->priv;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
int rc;
|
int rc;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#include <ipxe/list.h>
|
#include <ipxe/list.h>
|
||||||
#include <ipxe/if_ether.h>
|
#include <ipxe/if_ether.h>
|
||||||
#include <ipxe/iobuf.h>
|
#include <ipxe/iobuf.h>
|
||||||
#include <ipxe/uaccess.h>
|
|
||||||
#include <ipxe/netdevice.h>
|
#include <ipxe/netdevice.h>
|
||||||
#include <ipxe/features.h>
|
#include <ipxe/features.h>
|
||||||
#include <ipxe/interface.h>
|
#include <ipxe/interface.h>
|
||||||
@@ -391,8 +390,7 @@ static void aoecmd_ata_cmd ( struct aoe_command *aoecmd,
|
|||||||
if ( ! command->cb.lba48 )
|
if ( ! command->cb.lba48 )
|
||||||
aoeata->lba.bytes[3] |=
|
aoeata->lba.bytes[3] |=
|
||||||
( command->cb.device & ATA_DEV_MASK );
|
( command->cb.device & ATA_DEV_MASK );
|
||||||
copy_from_user ( aoeata->data, command->data_out, 0,
|
memcpy ( aoeata->data, command->data_out, command->data_out_len );
|
||||||
command->data_out_len );
|
|
||||||
|
|
||||||
DBGC2 ( aoedev, "AoE %s/%08x ATA cmd %02x:%02x:%02x:%02x:%08llx",
|
DBGC2 ( aoedev, "AoE %s/%08x ATA cmd %02x:%02x:%02x:%02x:%08llx",
|
||||||
aoedev_name ( aoedev ), aoecmd->tag, aoeata->aflags,
|
aoedev_name ( aoedev ), aoecmd->tag, aoeata->aflags,
|
||||||
@@ -452,8 +450,7 @@ static int aoecmd_ata_rsp ( struct aoe_command *aoecmd, const void *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Copy out data payload */
|
/* Copy out data payload */
|
||||||
copy_to_user ( command->data_in, 0, aoeata->data,
|
memcpy ( command->data_in, aoeata->data, command->data_in_len );
|
||||||
command->data_in_len );
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ static int fcpcmd_recv_rddata ( struct fcp_command *fcpcmd,
|
|||||||
fcpdev, fcpcmd->xchg_id, offset, ( offset + len ) );
|
fcpdev, fcpcmd->xchg_id, offset, ( offset + len ) );
|
||||||
|
|
||||||
/* Copy to user buffer */
|
/* Copy to user buffer */
|
||||||
copy_to_user ( command->data_in, offset, iobuf->data, len );
|
memcpy ( ( command->data_in + offset ), iobuf->data, len );
|
||||||
fcpcmd->offset += len;
|
fcpcmd->offset += len;
|
||||||
assert ( fcpcmd->offset <= command->data_in_len );
|
assert ( fcpcmd->offset <= command->data_in_len );
|
||||||
|
|
||||||
@@ -464,8 +464,8 @@ static int fcpcmd_send_wrdata ( struct fcp_command *fcpcmd ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Construct data IU frame */
|
/* Construct data IU frame */
|
||||||
copy_from_user ( iob_put ( iobuf, len ), command->data_out,
|
memcpy ( iob_put ( iobuf, len ),
|
||||||
fcpcmd->offset, len );
|
( command->data_out + fcpcmd->offset ), len );
|
||||||
memset ( &meta, 0, sizeof ( meta ) );
|
memset ( &meta, 0, sizeof ( meta ) );
|
||||||
meta.flags = ( XFER_FL_RESPONSE | XFER_FL_ABS_OFFSET );
|
meta.flags = ( XFER_FL_RESPONSE | XFER_FL_ABS_OFFSET );
|
||||||
meta.offset = fcpcmd->offset;
|
meta.offset = fcpcmd->offset;
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <ipxe/uaccess.h>
|
|
||||||
#include <ipxe/blocktrans.h>
|
#include <ipxe/blocktrans.h>
|
||||||
#include <ipxe/blockdev.h>
|
#include <ipxe/blockdev.h>
|
||||||
#include <ipxe/acpi.h>
|
#include <ipxe/acpi.h>
|
||||||
@@ -52,7 +51,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int http_block_read ( struct http_transaction *http, struct interface *data,
|
int http_block_read ( struct http_transaction *http, struct interface *data,
|
||||||
uint64_t lba, unsigned int count, userptr_t buffer,
|
uint64_t lba, unsigned int count, void *buffer,
|
||||||
size_t len ) {
|
size_t len ) {
|
||||||
struct http_request_range range;
|
struct http_request_range range;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -101,7 +100,7 @@ int http_block_read_capacity ( struct http_transaction *http,
|
|||||||
goto err_open;
|
goto err_open;
|
||||||
|
|
||||||
/* Insert block device translator */
|
/* Insert block device translator */
|
||||||
if ( ( rc = block_translate ( data, UNULL, HTTP_BLKSIZE ) ) != 0 ) {
|
if ( ( rc = block_translate ( data, NULL, HTTP_BLKSIZE ) ) != 0 ) {
|
||||||
DBGC ( http, "HTTP %p could not insert block translator: %s\n",
|
DBGC ( http, "HTTP %p could not insert block translator: %s\n",
|
||||||
http, strerror ( rc ) );
|
http, strerror ( rc ) );
|
||||||
goto err_translate;
|
goto err_translate;
|
||||||
|
|||||||
@@ -503,7 +503,7 @@ http_content_buffer ( struct http_transaction *http ) {
|
|||||||
__weak int http_block_read ( struct http_transaction *http __unused,
|
__weak int http_block_read ( struct http_transaction *http __unused,
|
||||||
struct interface *data __unused,
|
struct interface *data __unused,
|
||||||
uint64_t lba __unused, unsigned int count __unused,
|
uint64_t lba __unused, unsigned int count __unused,
|
||||||
userptr_t buffer __unused, size_t len __unused ) {
|
void *buffer __unused, size_t len __unused ) {
|
||||||
|
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
|||||||
#include <ipxe/open.h>
|
#include <ipxe/open.h>
|
||||||
#include <ipxe/scsi.h>
|
#include <ipxe/scsi.h>
|
||||||
#include <ipxe/process.h>
|
#include <ipxe/process.h>
|
||||||
#include <ipxe/uaccess.h>
|
|
||||||
#include <ipxe/tcpip.h>
|
#include <ipxe/tcpip.h>
|
||||||
#include <ipxe/settings.h>
|
#include <ipxe/settings.h>
|
||||||
#include <ipxe/features.h>
|
#include <ipxe/features.h>
|
||||||
@@ -478,7 +477,7 @@ static int iscsi_rx_data_in ( struct iscsi_session *iscsi,
|
|||||||
assert ( iscsi->command != NULL );
|
assert ( iscsi->command != NULL );
|
||||||
assert ( iscsi->command->data_in );
|
assert ( iscsi->command->data_in );
|
||||||
assert ( ( offset + len ) <= iscsi->command->data_in_len );
|
assert ( ( offset + len ) <= iscsi->command->data_in_len );
|
||||||
copy_to_user ( iscsi->command->data_in, offset, data, len );
|
memcpy ( ( iscsi->command->data_in + offset ), data, len );
|
||||||
|
|
||||||
/* Wait for whole SCSI response to arrive */
|
/* Wait for whole SCSI response to arrive */
|
||||||
if ( remaining )
|
if ( remaining )
|
||||||
@@ -598,8 +597,8 @@ static int iscsi_tx_data_out ( struct iscsi_session *iscsi ) {
|
|||||||
if ( ! iobuf )
|
if ( ! iobuf )
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
copy_from_user ( iob_put ( iobuf, len ),
|
memcpy ( iob_put ( iobuf, len ),
|
||||||
iscsi->command->data_out, offset, len );
|
( iscsi->command->data_out + offset ), len );
|
||||||
memset ( iob_put ( iobuf, pad_len ), 0, pad_len );
|
memset ( iob_put ( iobuf, pad_len ), 0, pad_len );
|
||||||
|
|
||||||
return xfer_deliver_iob ( &iscsi->socket, iobuf );
|
return xfer_deliver_iob ( &iscsi->socket, iobuf );
|
||||||
|
|||||||
Reference in New Issue
Block a user