Loading...
Searching...
No Matches
virtio_block.h
/* SPDX-License-Identifier: MIT */
/*
* (c) 2014 Sarah Hoffmann <sarah.hoffmann@kernkonzept.com>
*/
#pragma once
#include <l4/sys/types.h>
enum L4virtio_block_operations
{
L4VIRTIO_BLOCK_T_IN = 0,
L4VIRTIO_BLOCK_T_OUT = 1,
L4VIRTIO_BLOCK_T_FLUSH = 4,
L4VIRTIO_BLOCK_T_GET_ID = 8,
L4VIRTIO_BLOCK_T_DISCARD = 11,
L4VIRTIO_BLOCK_T_WRITE_ZEROES = 13,
};
enum L4virtio_block_status
{
L4VIRTIO_BLOCK_S_OK = 0,
L4VIRTIO_BLOCK_S_IOERR = 1,
L4VIRTIO_BLOCK_S_UNSUPP = 2
};
typedef struct l4virtio_block_header_t
{
l4_uint32_t type;
l4_uint32_t ioprio;
l4_uint64_t sector;
} l4virtio_block_header_t;
enum L4virtio_block_discard_flags_t
{
L4VIRTIO_BLOCK_DISCARD_F_UNMAP = 0x00000001UL,
L4VIRTIO_BLOCK_DISCARD_F_RESERVED = 0xFFFFFFFEUL,
};
typedef struct l4virtio_block_discard_t
{
l4_uint64_t sector;
l4_uint32_t num_sectors;
l4_uint32_t flags;
} l4virtio_block_discard_t;
typedef struct l4virtio_block_config_t
{
l4_uint64_t capacity;
l4_uint32_t size_max;
l4_uint32_t seg_max;
struct l4virtio_block_config_geometry_t
{
l4_uint16_t cylinders;
l4_uint8_t heads;
l4_uint8_t sectors;
} geometry;
l4_uint32_t blk_size;
struct l4virtio_block_config_topology_t
{
l4_uint8_t physical_block_exp;
l4_uint8_t alignment_offset;
l4_uint16_t min_io_size;
l4_uint32_t opt_io_size;
} topology;
l4_uint8_t writeback;
l4_uint8_t unused0[1];
l4_uint16_t num_queues;
l4_uint32_t max_discard_sectors;
l4_uint32_t max_discard_seg;
l4_uint32_t discard_sector_alignment;
l4_uint32_t max_write_zeroes_sectors;
l4_uint32_t max_write_zeroes_seg;
l4_uint8_t write_zeroes_may_unmap;
l4_uint8_t unused1[3];
} l4virtio_block_config_t;
l4_uint8_t
unsigned char l4_uint8_t
Unsigned 8bit value.
Definition l4int.h:25
l4_uint32_t
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:29
l4_uint16_t
unsigned short int l4_uint16_t
Unsigned 16bit value.
Definition l4int.h:27
l4_uint64_t
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:31
L4virtio_block_operations
L4virtio_block_operations
Kinds of operation over a block device.
Definition virtio_block.h:20
L4virtio_block_status
L4virtio_block_status
Status of a finished block request.
Definition virtio_block.h:33
L4VIRTIO_BLOCK_T_DISCARD
@ L4VIRTIO_BLOCK_T_DISCARD
Discard a range of sectors.
Definition virtio_block.h:25
L4VIRTIO_BLOCK_T_GET_ID
@ L4VIRTIO_BLOCK_T_GET_ID
Get device ID.
Definition virtio_block.h:24
L4VIRTIO_BLOCK_T_FLUSH
@ L4VIRTIO_BLOCK_T_FLUSH
Flush data to disk.
Definition virtio_block.h:23
L4VIRTIO_BLOCK_T_IN
@ L4VIRTIO_BLOCK_T_IN
Read from device.
Definition virtio_block.h:21
L4VIRTIO_BLOCK_T_OUT
@ L4VIRTIO_BLOCK_T_OUT
Write to device.
Definition virtio_block.h:22
L4VIRTIO_BLOCK_T_WRITE_ZEROES
@ L4VIRTIO_BLOCK_T_WRITE_ZEROES
Write zeroes to a range of sectors.
Definition virtio_block.h:26
L4VIRTIO_BLOCK_S_IOERR
@ L4VIRTIO_BLOCK_S_IOERR
IO error on device.
Definition virtio_block.h:35
L4VIRTIO_BLOCK_S_UNSUPP
@ L4VIRTIO_BLOCK_S_UNSUPP
Operation is not supported.
Definition virtio_block.h:36
L4VIRTIO_BLOCK_S_OK
@ L4VIRTIO_BLOCK_S_OK
Request finished successfully.
Definition virtio_block.h:34
types.h
Common L4 ABI Data Types.
l4virtio_block_config_t
Device configuration for block devices.
Definition virtio_block.h:69
l4virtio_block_config_t::seg_max
l4_uint32_t seg_max
Maximum number of segments per request.
Definition virtio_block.h:72
l4virtio_block_config_t::blk_size
l4_uint32_t blk_size
Block size of underlying disk.
Definition virtio_block.h:79
l4virtio_block_config_t::size_max
l4_uint32_t size_max
Maximum size of a single segment.
Definition virtio_block.h:71
l4virtio_block_config_t::capacity
l4_uint64_t capacity
Capacity of device in 512-byte sectors.
Definition virtio_block.h:70
l4virtio_block_discard_t
Structure used for the write zeroes and discard commands.
Definition virtio_block.h:59
l4virtio_block_header_t
Header structure of a request for a block device.
Definition virtio_block.h:43
l4virtio_block_header_t::type
l4_uint32_t type
Kind of request, see L4virtio_block_operations.
Definition virtio_block.h:44
l4virtio_block_header_t::ioprio
l4_uint32_t ioprio
Priority (unused).
Definition virtio_block.h:45
l4virtio_block_header_t::sector
l4_uint64_t sector
First sector to read/write.
Definition virtio_block.h:46