Skip to content

Commit

Permalink
Fix style for virtio/block.c and uio_tools/blk.c
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Velickovic <[email protected]>
  • Loading branch information
Ivan-Velickovic committed Jul 22, 2024
1 parent 6f51b05 commit 9dcf440
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion examples/virtio-snd/include/serial_config/serial_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static inline void serial_virt_queue_init_sys(char *pd_name, serial_queue_handle
serial_queue_init(&cli_queue_handle[1], (serial_queue_t *)(cli_queue_ptr + SERIAL_QUEUE_SIZE),
SERIAL_RX_DATA_REGION_SIZE_CLI1, (char *)(cli_data + SERIAL_RX_DATA_REGION_SIZE_CLI0));
serial_queue_init(&cli_queue_handle[2], (serial_queue_t *)(cli_queue_ptr + 2 * SERIAL_QUEUE_SIZE),
SERIAL_RX_DATA_REGION_SIZE_CLI2,
SERIAL_RX_DATA_REGION_SIZE_CLI2,
(char *)(cli_data + SERIAL_RX_DATA_REGION_SIZE_CLI0 + SERIAL_RX_DATA_REGION_SIZE_CLI1));
} else if (!sddf_strcmp(pd_name, SERIAL_VIRT_TX_NAME)) {
serial_queue_init(cli_queue_handle, cli_queue, SERIAL_TX_DATA_REGION_SIZE_CLI0, cli_data);
Expand Down
2 changes: 1 addition & 1 deletion examples/virtio/include/serial_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static inline void serial_virt_queue_init_sys(char *pd_name, serial_queue_handle
serial_queue_init(&cli_queue_handle[1], (serial_queue_t *)(cli_queue_ptr + SERIAL_QUEUE_SIZE),
SERIAL_RX_DATA_REGION_SIZE_CLI1, (char *)(cli_data + SERIAL_RX_DATA_REGION_SIZE_CLI0));
serial_queue_init(&cli_queue_handle[2], (serial_queue_t *)(cli_queue_ptr + 2 * SERIAL_QUEUE_SIZE),
SERIAL_RX_DATA_REGION_SIZE_CLI2,
SERIAL_RX_DATA_REGION_SIZE_CLI2,
(char *)(cli_data + SERIAL_RX_DATA_REGION_SIZE_CLI0 + SERIAL_RX_DATA_REGION_SIZE_CLI1));
} else if (!sddf_strcmp(pd_name, SERIAL_VIRT_TX_NAME)) {
serial_queue_init(cli_queue_handle, cli_queue, SERIAL_TX_DATA_REGION_SIZE_CLI0, cli_data);
Expand Down
38 changes: 20 additions & 18 deletions src/virtio/block.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ static int virtio_blk_mmio_queue_notify(struct virtio_device *dev)
/* Book keep the request */
uint32_t req_id;
ialloc_alloc(&state->ialloc, &req_id);
state->reqbk[req_id] = (reqbk_t){
state->reqbk[req_id] = (reqbk_t) {
desc_head, sddf_data, sddf_count, sddf_block_number,
virtio_data, virtio_data_size, 0
virtio_data, virtio_data_size, 0
};

uintptr_t offset = sddf_data - ((struct virtio_blk_device *)dev->device_data)->data_region;
Expand Down Expand Up @@ -287,9 +287,9 @@ static int virtio_blk_mmio_queue_notify(struct virtio_device *dev)
/* Book keep the request */
uint32_t req_id;
ialloc_alloc(&state->ialloc, &req_id);
state->reqbk[req_id] = (reqbk_t){
state->reqbk[req_id] = (reqbk_t) {
desc_head, sddf_data, sddf_count, sddf_block_number,
virtio_data, virtio_data_size, aligned
virtio_data, virtio_data_size, aligned
};

uintptr_t offset = sddf_data - ((struct virtio_blk_device *)dev->device_data)->data_region;
Expand All @@ -313,9 +313,9 @@ static int virtio_blk_mmio_queue_notify(struct virtio_device *dev)
/* Book keep the request */
uint32_t req_id;
ialloc_alloc(&state->ialloc, &req_id);
state->reqbk[req_id] = (reqbk_t){
state->reqbk[req_id] = (reqbk_t) {
desc_head, sddf_data, sddf_count, sddf_block_number,
virtio_data, virtio_data_size, aligned
virtio_data, virtio_data_size, aligned
};

/* Copy data from virtio buffer to data buffer, create sddf write request and initialise it with data buffer */
Expand All @@ -341,7 +341,9 @@ static int virtio_blk_mmio_queue_notify(struct virtio_device *dev)
ialloc_alloc(&state->ialloc, &req_id);
/* except for virtio desc, nothing else needs to be retrieved later
* so leave as 0 */
state->reqbk[req_id] = (reqbk_t){desc_head, 0, 0, 0, 0, 0};
state->reqbk[req_id] = (reqbk_t) {
desc_head, 0, 0, 0, 0, 0
};

err = blk_enqueue_req(&state->queue_h, FLUSH, 0, 0, 0, req_id);
break;
Expand Down Expand Up @@ -422,10 +424,10 @@ bool virtio_blk_handle_resp(struct virtio_blk_device *state)

uint32_t new_sddf_id;
ialloc_alloc(&state->ialloc, &new_sddf_id);
state->reqbk[new_sddf_id] = (reqbk_t){
state->reqbk[new_sddf_id] = (reqbk_t) {
data->virtio_desc_head,
data->sddf_data, data->sddf_count,
data->sddf_block_number, 0, 0, true
data->sddf_data, data->sddf_count,
data->sddf_block_number, 0, 0, true
};

err = blk_enqueue_req(&state->queue_h,
Expand Down Expand Up @@ -503,14 +505,14 @@ static virtio_device_funs_t functions = {
};

bool virtio_mmio_blk_init(struct virtio_blk_device *blk_dev,
uintptr_t region_base,
uintptr_t region_size,
size_t virq,
uintptr_t data_region,
size_t data_region_size,
blk_storage_info_t *storage_info,
blk_queue_handle_t *queue_h,
int server_ch)
uintptr_t region_base,
uintptr_t region_size,
size_t virq,
uintptr_t data_region,
size_t data_region_size,
blk_storage_info_t *storage_info,
blk_queue_handle_t *queue_h,
int server_ch)
{
struct virtio_device *dev = &blk_dev->virtio_device;

Expand Down
4 changes: 2 additions & 2 deletions tools/linux/uio_drivers/blk/blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ int driver_init(void **maps, uintptr_t *maps_phys, int num_maps, int argc, char
blk_config->capacity = size / BLK_TRANSFER_SIZE;

LOG_UIO_BLOCK("Raw block device: read_only=%d, sector_size=%d, size=%ld\n", (int)blk_config->read_only,
blk_config->sector_size, blk_config->size);
blk_config->sector_size, blk_config->size);

/* Optimal size */
/* As far as I know linux does not let you query this from userspace, set as 0 to mean undefined */
blk_config->block_size = 0;

/* Driver is ready to go, set ready in shared config page */
__atomic_store_n(&blk_config->ready, true, __ATOMIC_RELEASE);

Expand Down

0 comments on commit 9dcf440

Please sign in to comment.