#include <machine.hpp>
class MachineDefined in include/machine.hpp:50
RV64-VM Main machine class.
This class implements RISC-V emulator machine.
| Name | Kind | Owner |
|---|---|---|
virtio_count |
variable |
Declared here |
Machine |
function |
Declared here |
~Machine |
function |
Declared here |
start_init |
function |
Declared here |
end_init |
function |
Declared here |
run |
function |
Declared here |
stop |
function |
Declared here |
reset |
function |
Declared here |
wait |
function |
Declared here |
get_mmio |
function |
Declared here |
get_fdt |
function |
Declared here |
get_timebase |
function |
Declared here |
get_mmap |
function |
Declared here |
get_state |
function |
Declared here |
get_memory_size |
function |
Declared here |
get_hart_count |
function |
Declared here |
get_hart |
function |
Declared here |
load_vd_image |
function |
Declared here |
load_bios |
function |
Declared here |
load_kernel |
function |
Declared here |
load_dtb |
function |
Declared here |
get_vd_image |
function |
Declared here |
set_uart_output |
function |
Declared here |
get_uart_output |
function |
Declared here |
MachineState |
enum |
Declared here |
| Return | Name | Description |
|---|---|---|
int |
virtio_count |
VirtIO devices counter. |
int virtio_count = 0Defined in include/machine.hpp:247
VirtIO devices counter.
| Return | Name | Description |
|---|---|---|
Machine |
Machine constructor. | |
~Machine |
Machine destructor. | |
void |
start_init inline |
Device initialization start. |
void |
end_init inline |
Device initialization end. |
void |
run |
Runs machine. |
void |
stop |
Stops machine. |
void |
reset |
Resets machines. |
void |
wait |
Joins machine work thread. |
MMIO * |
get_mmio inline |
Returns MMIO pointer. |
fdt_node * |
get_fdt inline |
Returns FDT pointer. |
uint64_t |
get_timebase const inline |
Returns config specified timer timebase (Hz/S) |
MemoryMap * |
get_mmap inline |
Returns MemoryMap pointer. |
MachineState |
get_state const inline |
Returns Machine internal state. |
uint64_t |
get_memory_size const inline |
Returns config specified RAM size. |
uint8_t |
get_hart_count const inline |
Returns config specified Hart count. |
Hart & |
get_hart inline |
Returns specified Hart by index. |
bool |
load_vd_image |
Loads Image file to VirtIO-Blk. |
bool |
load_bios |
Loads Firmware file. |
bool |
load_kernel |
Loads Kernel file. |
bool |
load_dtb |
Loads DTB file. |
FILE * |
get_vd_image |
Returns FILE pointer to loaded VirtIO-Blk file. |
void |
set_uart_output |
Sets UART output stream. |
FILE * |
get_uart_output |
Returns UART output stream. |
Machine(constMachineConfig & cfg)Defined in include/machine.hpp:69
Machine constructor.
Creates RISC-V machine
See also: MachineConfig
| Parameter | Type | Description |
|---|---|---|
cfg |
constMachineConfig & |
Machine configuration |
~Machine()Defined in include/machine.hpp:75
Machine destructor.
Destroys RISC-V machine
Note
It is recommended to stop machine before destroy it.
inline
inline void start_init()Defined in include/machine.hpp:86
Device initialization start.
Creates FDT Base for all devices In this block you supposed to create all devices you want, or load DTB from file.
inline
inline void end_init()Defined in include/machine.hpp:96
Device initialization end.
Writes FDT to memory. This function must be called after you created all devices you wanted.
void run()Defined in include/machine.hpp:105
Runs machine.
Starts all Hart's execution loop.
void stop()Defined in include/machine.hpp:111
Stops machine.
Sends a signal to machine so it could stop and destroy all harts safely.
Note
In that moment it joins work thread.
void reset()Defined in include/machine.hpp:117
Resets machines.
Sends a signal to machine so it could safely recreate all HART's.
Warning
Untested, but it is not recommended to first-time start machine with this function.
void wait()Defined in include/machine.hpp:121
Joins machine work thread.
inline
inline MMIO * get_mmio()Defined in include/machine.hpp:128
Returns MMIO pointer.
See also: MMIO
MMIO Pointer
inline
inline fdt_node * get_fdt()Defined in include/machine.hpp:134
Returns FDT pointer.
See also: libfdt.h
FDT pointer
const inline
inline uint64_t get_timebase() constDefined in include/machine.hpp:139
Returns config specified timer timebase (Hz/S)
Timebase number
inline
inline MemoryMap * get_mmap()Defined in include/machine.hpp:145
Returns MemoryMap pointer.
See also: MemoryMap
MemoryMap pointer
const inline
inline MachineState get_state() constDefined in include/machine.hpp:152
Returns Machine internal state.
See also: MachineState
Machine State enum
const inline
inline uint64_t get_memory_size() constDefined in include/machine.hpp:157
Returns config specified RAM size.
Memory Size (bytes)
const inline
inline uint8_t get_hart_count() constDefined in include/machine.hpp:163
Returns config specified Hart count.
See also: HART
HART count
inline
inline Hart & get_hart(size_t index)Defined in include/machine.hpp:170
Returns specified Hart by index.
See also: Hart
Hart object
| Parameter | Type | Description |
|---|---|---|
index |
size_t |
HART index (not ID!) |
bool load_vd_image(const std::string & path)Defined in include/machine.hpp:177
Loads Image file to VirtIO-Blk.
Success bool
| Parameter | Type | Description |
|---|---|---|
path |
const std::string & |
Image path |
bool load_bios(const std::string & path)Defined in include/machine.hpp:183
Loads Firmware file.
Success bool
| Parameter | Type | Description |
|---|---|---|
path |
const std::string & |
Firmware path |
bool load_kernel(const std::string & path)Defined in include/machine.hpp:189
Loads Kernel file.
Success bool
| Parameter | Type | Description |
|---|---|---|
path |
const std::string & |
Kernel path |
bool load_dtb(const std::string & path)Defined in include/machine.hpp:197
Loads DTB file.
Loads custom FDT from DTB to memory.
Note
Make sure to set init_fdt in config to false before init!
Success bool
| Parameter | Type | Description |
|---|---|---|
path |
const std::string & |
DTB path |
FILE * get_vd_image(int idx)Defined in include/machine.hpp:203
Returns FILE pointer to loaded VirtIO-Blk file.
FILE pointer
| Parameter | Type | Description |
|---|---|---|
idx |
int |
Image index |
void set_uart_output(FILE * stream)Defined in include/machine.hpp:208
Sets UART output stream.
| Parameter | Type | Description |
|---|---|---|
stream |
FILE * |
Output stream |
FILE * get_uart_output()Defined in include/machine.hpp:213
Returns UART output stream.
Output stream
| Name | Description |
|---|---|
MachineState |
Machine State enum. |
enum MachineStateDefined in include/machine.hpp:56
Machine State enum.
| Value | Description |
|---|---|
Off |
|
Halted |
Powered off |
Running |
Awaiting any command |
Resetting |
Self-explanatory |