We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 86e6b16 commit 350d08fCopy full SHA for 350d08f
1 file changed
README.md
@@ -27,3 +27,31 @@ Use the following command to self sign your binary for local development:
27
```bash
28
$ codesign --sign - --force --entitlements=example.entitlements ./binary
29
```
30
+
31
+## Example
32
33
+Here is basic "Hello world" example on Apple Silicon:
34
+```rust
35
+// Init VM
36
+hv::Vm::create_vm(ptr::null_mut())?;
37
38
+// Initialize guest memory
39
+hv::Vm::map(load_addr, GUEST_ADDR as _, MEM_SIZE as _, hv::Memory::READ)?;
40
41
+// Create VCPU
42
+let cpu = hv::Vm::create_cpu()?;
43
44
+// Register regs
45
+cpu.set_reg(Reg::PC, GUEST_ADDR)?;
46
+cpu.set_reg(Reg::X1, GUEST_RESULT_ADDR)?;
47
48
+// Run CPU
49
+loop {
50
+ cpu.run()?;
51
52
+ let info = cpu.exit_info();
53
+ println!("{:?}", info);
54
55
+ break;
56
+}
57
+```
0 commit comments