Skip to main content

NativeCpu

Struct NativeCpu 

Source
pub struct NativeCpu { /* private fields */ }
Expand description

Native CPU state arena and guest memory owner.

v86’s scalar CPU state uses the first 4 KiB of the arena. The guest RAM is allocated by the core memory module and addressed with 32-bit guest physical addresses, matching the original emulator model.

Implementations§

Source§

impl NativeCpu

Source

pub fn new(ram_bytes: u32, vga_bytes: u32) -> Self

Source

pub fn ram_bytes(&self) -> u32

Source

pub fn vga_bytes(&self) -> u32

Source

pub fn step(&mut self, max_instructions: u32) -> u32

Source

pub fn read_memory(&self, address: u32, output: &mut [u8]) -> bool

Source

pub fn write_memory(&mut self, address: u32, input: &[u8]) -> bool

Source

pub fn instruction_pointer(&self) -> u32

Source

pub fn halted(&self) -> bool

Source

pub fn state_arena(&self) -> &[u8; 4096]

Source

pub fn vga_framebuffer_rgb(&self) -> Option<(u32, u32, Vec<u8>)>

Return the restored SVGA framebuffer as packed RGB bytes. The native runtime keeps the framebuffer in the same guest-visible backing store used by v86’s LFB mapping.

Source

pub fn set_9p_root(&mut self, path: impl AsRef<Path>) -> Result<(), String>

Source§

impl NativeCpu

Source

pub fn restore_v86_state( &mut self, state: &Value, buffers: &[Vec<u8>], ) -> Result<(), String>

Restore the CPU scalar state and packed RAM representation from the decoded v86 state object. Device arrays are intentionally left to the outer native device graph, but CPU execution can continue after this method completes.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.