ducky.boot module¶
This file provides necessary code to allow boot up of a virtual machine with the correct program running. This code can provide slightly different environment when compared to real hardware process, since e.g. external files can be mmap-ed into VM’s memory for writing.
-
ducky.boot.
DEFAULT_BOOTLOADER_ADDRESS
= 131072¶ By default, CPU starts executing instructions at this address after boot.
-
ducky.boot.
DEFAULT_HDT_ADDRESS
= 256¶ By default, Hardware Description Table starts at this address after boot.
-
class
ducky.boot.
MMapArea
(ptr, address, size, file_path, offset, pages_start, pages_cnt, flags)[source]¶ Bases:
object
Objects of this class represent one mmaped memory area each, to track this information for later use.
Parameters: - ptr –
mmap object
, as returned by mmap.mmap function. - address (u32_t) – address of the first byte of an area in the memory.
- size (u32_t) – length of the area, in bytes.
- file_path – path to a source file.
- offset (u32_t) – offset of the first byte in the source file.
- pages_start (int) – first page of the area.
- pages_cnt (int) – number of pages in the area.
- flags (mm.binary.SectionFlags) – flags applied to this area.
- ptr –
-
class
ducky.boot.
MMapAreaState
[source]¶ Bases:
ducky.snapshot.SnapshotNode
-
class
ducky.boot.
MMapMemoryPage
(area, *args, **kwargs)[source]¶ Bases:
ducky.mm.ExternalMemoryPage
Memory page backed by an external file that is accessible via
mmap()
call. It’s a part of one of mm.MMapArea instances, and if such area was opened as shared, every change in this page content will affect the content of external file, and vice versa, every change of external file will be reflected in content of this page (if this page lies in affected area).Parameters: area (MMapArea) – area this page belongs to.
-
class
ducky.boot.
ROMLoader
(machine)[source]¶ Bases:
ducky.interfaces.IMachineWorker
-
mmap_area
(file_path, address, size, offset=0, flags=None, shared=False)[source]¶ Assign set of memory pages to mirror external file, mapped into memory.
Parameters: - file_path (string) – path of external file, whose content new area should reflect.
- address (u24) – address where new area should start.
- size (u24) – length of area, in bytes.
- offset (int) – starting point of the area in mmaped file.
- flags (ducky.mm.binary.SectionFlags) – specifies required flags for mmaped pages.
- shared (bool) – if
True
, content of external file is mmaped as shared, i.e. all changes are visible to all processes, not only to the current ducky virtual machine.
Returns: newly created mmap area.
Return type: ducky.mm.MMapArea
Raises: ducky.errors.InvalidResourceError – when
size
is not multiply ofducky.mm.PAGE_SIZE
, or whenaddress
is not multiply ofducky.mm.PAGE_SIZE
, or when any of pages in the affected area is already allocated.
-
setup_hdt
()[source]¶ Initialize memory area that contains HDT.
If VM config file specifies HDT image file, it is loaded, otherwise HDT is constructed for the actual configuration. It is then copied into memory.
Parameters: - machine.hdt-address (u32_t) – Base address of HDT in memory. If not set,
ducky.boot.DEFAULT_HDT_ADDRESS
is used. - machine.hdt-image – HDT image to load. If not set, HDT is constructed for the actual VM’s configuration.
- machine.hdt-address (u32_t) – Base address of HDT in memory. If not set,
-