ducky.devices.storage module¶
Persistent storage support.
Several different persistent storages can be attached to a virtual machine, each with its own id. This module provides methods for manipulating their content. By default, storages operate with blocks of constant, standard size, though this is not a mandatory requirement - storage with different block size, or even with variable block size can be implemented.
Each block has its own id. Block IO operations read or write one or more blocks to or from a device. IO is requested by invoking the virtual interrupt, with properly set values in registers.
-
ducky.devices.storage.
BLOCK_SIZE
= 1024¶ Size of block, in bytes.
-
class
ducky.devices.storage.
BlockIO
(machine, name, port=None, irq=None, *args, **kwargs)[source]¶ Bases:
ducky.devices.IRQProvider
,ducky.devices.IOProvider
,ducky.devices.Device
-
class
ducky.devices.storage.
FileBackedStorage
(machine, name, filepath=None, *args, **kwargs)[source]¶ Bases:
ducky.devices.storage.Storage
Storage that saves its content into a regular file.
-
class
ducky.devices.storage.
Storage
(machine, name, sid=None, size=None, *args, **kwargs)[source]¶ Bases:
ducky.devices.Device
Base class for all block storages.
Parameters: - machine (ducky.machine.Machine) – machine storage is attached to.
- sid (int) – id of storage.
- size (int) – size of storage, in bytes.
-
do_read_blocks
(start, cnt)[source]¶ Read one or more blocks from device to internal buffer.
Child classes are supposed to reimplement this particular method.
Parameters: - start (u32_t) – index of the first requested block.
- cnt (u32_t) – number of blocks to read.
-
do_write_blocks
(start, cnt, buff)[source]¶ Write one or more blocks from internal buffer to device.
Child classes are supposed to reimplement this particular method.
Parameters: - start (u32_t) – index of the first requested block.
- cnt (u32_t) – number of blocks to write.
-
read_blocks
(start, cnt)[source]¶ Read one or more blocks from device to internal buffer.
Child classes should not reimplement this method, as it provides checks common for (probably) all child classes.
Parameters: - start (u32_t) – index of the first requested block.
- cnt (u32_t) – number of blocks to read.
-
write_blocks
(start, cnt, buff)[source]¶ Write one or more blocks from internal buffer to device.
Child classes should not reimplement this method, as it provides checks common for (probably) all child classes.
Parameters: - start (u32_t) – index of the first requested block.
- cnt (u32_t) – number of blocks to write.