#include <debug.h>
#include <malloc.h>
#include <string.h>
#include <block/device.h>
#include <buffer.h>
#include <workqueue.h>
#include <app/workqueue.h>
#include <app/config_dmapool.h>
#include <block/copy.h>

Go to the source code of this file.
Functions | |
| struct block_copy_request * | block_copy_alloc (uint32_t nr_blocks, uint32_t block_size, void *data) |
| Allocate a block copy request and its buffers. | |
| void | block_copy_free (struct block_copy_request *request) |
| Free block copy request. | |
| int | block_copy_set_source (struct block_copy_request *req, struct block_device *dev, block_addr_t lba) |
| Set source device and blocks for the block copy. | |
| int | block_copy_set_dest (struct block_copy_request *req, struct block_device *dev, block_addr_t lba) |
| Set target device and blocks for the block copy. | |
| void | block_copy_set_completion_callback (struct block_copy_request *req, void(*callback)(struct block_copy_request *, uint32_t, void *)) |
| Set completion callback. | |
| void | block_copy_set_progress_callback (struct block_copy_request *req, void(*callback)(struct block_copy_request *, uint32_t, void *)) |
| Set progress callback. | |
| void | block_copy_submit (struct block_copy_request *req) |
| Submit a block copy request. | |
This file contains the functionality needed to copy a chunk of blocks from one block device to another.
Definition in file copy.c.
| struct block_copy_request* block_copy_alloc | ( | uint32_t | nr_blocks, | |
| uint32_t | block_size, | |||
| void * | data | |||
| ) | [read] |
Allocate a block copy request and its buffers.
This function will allocate a block copy request with as many buffers as necessary, up to the maximum available memory. If it is not able to allocate the minimum memory needed, or the block size given is not supported, NULL is returned.
| nr_blocks | The number of blocks to copy | |
| block_size | The size of each block in bytes | |
| data | Context data passed to callbacks |
Definition at line 201 of file copy.c.
References assert, block_copy_request::block_size, block_copy_request::blocks_allocated, block_copy_request::blocks_pr_buf, block_copy_request::buffer_list, block_copy_request::data, block_copy_request::length, memset(), buffer::node, slist_init(), and slist_insert_tail().

| void block_copy_free | ( | struct block_copy_request * | request | ) |
Free block copy request.
This function will free all memory allocated to the block copy request, including all allocated buffers and requests.
| request | Block copy request descriptor |
Definition at line 273 of file copy.c.
References block_free_request(), block_copy_request::buffer_list, buffer::node, block_copy_request::read_req, slist_is_empty(), slist_pop_head, block_copy_request::source, block_copy_request::target, and block_copy_request::write_req.

| void block_copy_set_completion_callback | ( | struct block_copy_request * | req, | |
| void(*)(struct block_copy_request *, uint32_t, void *) | callback | |||
| ) |
Set completion callback.
This function will set the callback called when the block copy request completes. The callback will also be called if the block copy fails for some reason; an error code can then be found in the status field.
| req | Block copy request descriptor | |
| callback | Completion callback |
Definition at line 371 of file copy.c.
References assert, and block_copy_request::completion_callback.
| int block_copy_set_dest | ( | struct block_copy_request * | req, | |
| struct block_device * | dev, | |||
| block_addr_t | lba | |||
| ) |
Set target device and blocks for the block copy.
This function will set the target device and the address of the first block to copy to in the block copy request descriptor.
| req | Block copy request descriptor | |
| dev | Target device | |
| lba | Address of first target block |
Definition at line 338 of file copy.c.
References assert, block_alloc_request(), BLOCK_COPY_BLOCK_SIZE_MISMATCH, BLOCK_COPY_NOMEM, block_device::block_size, block_copy_request::block_size, block_request::context, block_request::req_done, block_copy_request::target, block_copy_request::target_start, and block_copy_request::write_req.

| void block_copy_set_progress_callback | ( | struct block_copy_request * | req, | |
| void(*)(struct block_copy_request *, uint32_t, void *) | callback | |||
| ) |
Set progress callback.
This function will set the callback called as the block copy request progresses. The callback will be called after each successful write operation, except for the last write in the request.
| req | Block copy request descriptor | |
| callback | Progress callback |
Definition at line 390 of file copy.c.
References assert, and block_copy_request::progress_callback.
| int block_copy_set_source | ( | struct block_copy_request * | req, | |
| struct block_device * | dev, | |||
| block_addr_t | lba | |||
| ) |
Set source device and blocks for the block copy.
This function will set the source device and the address of the first block to copy from the source in the block copy request descriptor.
| req | Block copy request descriptor | |
| dev | Source device | |
| lba | Address of first source block |
Definition at line 304 of file copy.c.
References assert, block_alloc_request(), BLOCK_COPY_BLOCK_SIZE_MISMATCH, BLOCK_COPY_NOMEM, block_device::block_size, block_copy_request::block_size, block_request::context, block_copy_request::read_req, block_request::req_done, block_copy_request::source, and block_copy_request::source_start.

| void block_copy_submit | ( | struct block_copy_request * | req | ) |
Submit a block copy request.
This function will submit a block copy request and start the actual copying. When the operation has completed the completion callback set by block_copy_set_completion_callback() is executed.
| req | Block copy request descriptor |
Definition at line 408 of file copy.c.
References assert, block_copy_request::read_req, block_copy_request::source, block_copy_request::target, block_copy_request::total_blocks_copied, and block_copy_request::write_req.
1.5.8