virtual-machine 0.0.0-rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.yarn/install-state.gz +0 -0
- package/.yarnrc.yml +1 -0
- package/Cargo.toml +48 -0
- package/build/cli.js +904 -0
- package/build/index.d.ts +127 -0
- package/build/index.js +723 -0
- package/build/index.mjs +17 -0
- package/build/riscv_vm-CYH5SWIJ.mjs +672 -0
- package/build.sh +26 -0
- package/cli.ts +251 -0
- package/index.ts +15 -0
- package/package.json +30 -0
- package/src/bus.rs +558 -0
- package/src/clint.rs +132 -0
- package/src/console.rs +83 -0
- package/src/cpu.rs +1913 -0
- package/src/csr.rs +67 -0
- package/src/decoder.rs +789 -0
- package/src/dram.rs +146 -0
- package/src/emulator.rs +603 -0
- package/src/lib.rs +270 -0
- package/src/main.rs +363 -0
- package/src/mmu.rs +331 -0
- package/src/net.rs +121 -0
- package/src/net_tap.rs +164 -0
- package/src/net_webtransport.rs +446 -0
- package/src/net_ws.rs +396 -0
- package/src/plic.rs +261 -0
- package/src/uart.rs +233 -0
- package/src/virtio.rs +1074 -0
- package/tsconfig.json +19 -0
- package/tsup/index.ts +80 -0
- package/tsup/tsup.cli.ts +8 -0
- package/tsup/tsup.core.cjs.ts +7 -0
- package/tsup/tsup.core.esm.ts +8 -0
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Network connection status for the WASM VM.
|
|
5
|
+
*/
|
|
6
|
+
declare enum NetworkStatus {
|
|
7
|
+
Disconnected = 0,
|
|
8
|
+
Connecting = 1,
|
|
9
|
+
Connected = 2,
|
|
10
|
+
Error = 3,
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* WASM-exposed VM wrapper for running RISC-V kernels in the browser.
|
|
14
|
+
*/
|
|
15
|
+
declare class WasmVm {
|
|
16
|
+
free(): void;
|
|
17
|
+
[Symbol.dispose](): void;
|
|
18
|
+
/**
|
|
19
|
+
* Get a byte from the UART output buffer, if available.
|
|
20
|
+
*/
|
|
21
|
+
get_output(): number | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Get the current network connection status.
|
|
24
|
+
*/
|
|
25
|
+
network_status(): NetworkStatus;
|
|
26
|
+
/**
|
|
27
|
+
* Connect to a WebSocket relay server for networking.
|
|
28
|
+
* The URL should be like "ws://localhost:8765".
|
|
29
|
+
*/
|
|
30
|
+
connect_network(ws_url: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get current memory usage (DRAM size) in bytes.
|
|
33
|
+
*/
|
|
34
|
+
get_memory_usage(): bigint;
|
|
35
|
+
/**
|
|
36
|
+
* Disconnect from the network.
|
|
37
|
+
*/
|
|
38
|
+
disconnect_network(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Connect to a WebTransport relay server.
|
|
41
|
+
*/
|
|
42
|
+
connect_webtransport(url: string, cert_hash?: string | null): void;
|
|
43
|
+
/**
|
|
44
|
+
* Create a new VM instance and load a kernel (ELF or raw binary).
|
|
45
|
+
*/
|
|
46
|
+
constructor(kernel: Uint8Array);
|
|
47
|
+
/**
|
|
48
|
+
* Execute a single instruction.
|
|
49
|
+
*/
|
|
50
|
+
step(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Push an input byte to the UART.
|
|
53
|
+
*/
|
|
54
|
+
input(byte: number): void;
|
|
55
|
+
/**
|
|
56
|
+
* Load a disk image and attach it as a VirtIO block device.
|
|
57
|
+
* This should be called before starting execution if the kernel needs a filesystem.
|
|
58
|
+
*/
|
|
59
|
+
load_disk(disk_image: Uint8Array): void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
63
|
+
|
|
64
|
+
interface InitOutput {
|
|
65
|
+
readonly memory: WebAssembly.Memory;
|
|
66
|
+
readonly __wbg_wasmvm_free: (a: number, b: number) => void;
|
|
67
|
+
readonly wasmvm_connect_network: (a: number, b: number, c: number) => [number, number];
|
|
68
|
+
readonly wasmvm_connect_webtransport: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
69
|
+
readonly wasmvm_disconnect_network: (a: number) => void;
|
|
70
|
+
readonly wasmvm_get_memory_usage: (a: number) => bigint;
|
|
71
|
+
readonly wasmvm_get_output: (a: number) => number;
|
|
72
|
+
readonly wasmvm_input: (a: number, b: number) => void;
|
|
73
|
+
readonly wasmvm_load_disk: (a: number, b: number, c: number) => void;
|
|
74
|
+
readonly wasmvm_network_status: (a: number) => number;
|
|
75
|
+
readonly wasmvm_new: (a: number, b: number) => [number, number, number];
|
|
76
|
+
readonly wasmvm_step: (a: number) => void;
|
|
77
|
+
readonly wasm_bindgen__convert__closures_____invoke__hcf26143a2d2b8df4: (a: number, b: number) => void;
|
|
78
|
+
readonly wasm_bindgen__closure__destroy__h158587509e69fed9: (a: number, b: number) => void;
|
|
79
|
+
readonly wasm_bindgen__convert__closures_____invoke__h5116ef40c5ca7cd6: (a: number, b: number, c: any) => void;
|
|
80
|
+
readonly wasm_bindgen__convert__closures_____invoke__h6fd3101b14d9814b: (a: number, b: number, c: any) => void;
|
|
81
|
+
readonly wasm_bindgen__closure__destroy__hb2f3fe1158f30bc9: (a: number, b: number) => void;
|
|
82
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
83
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
84
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
85
|
+
readonly __externref_table_alloc: () => number;
|
|
86
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
87
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
88
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
89
|
+
readonly __wbindgen_start: () => void;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
93
|
+
/**
|
|
94
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
95
|
+
* a precompiled `WebAssembly.Module`.
|
|
96
|
+
*
|
|
97
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
98
|
+
*
|
|
99
|
+
* @returns {InitOutput}
|
|
100
|
+
*/
|
|
101
|
+
declare function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
105
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
106
|
+
*
|
|
107
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
108
|
+
*
|
|
109
|
+
* @returns {Promise<InitOutput>}
|
|
110
|
+
*/
|
|
111
|
+
declare function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
112
|
+
|
|
113
|
+
type __pkg_riscv_vm_InitInput = InitInput;
|
|
114
|
+
type __pkg_riscv_vm_InitOutput = InitOutput;
|
|
115
|
+
type __pkg_riscv_vm_NetworkStatus = NetworkStatus;
|
|
116
|
+
declare const __pkg_riscv_vm_NetworkStatus: typeof NetworkStatus;
|
|
117
|
+
type __pkg_riscv_vm_SyncInitInput = SyncInitInput;
|
|
118
|
+
type __pkg_riscv_vm_WasmVm = WasmVm;
|
|
119
|
+
declare const __pkg_riscv_vm_WasmVm: typeof WasmVm;
|
|
120
|
+
declare const __pkg_riscv_vm_initSync: typeof initSync;
|
|
121
|
+
declare namespace __pkg_riscv_vm {
|
|
122
|
+
export { type __pkg_riscv_vm_InitInput as InitInput, type __pkg_riscv_vm_InitOutput as InitOutput, __pkg_riscv_vm_NetworkStatus as NetworkStatus, type __pkg_riscv_vm_SyncInitInput as SyncInitInput, __pkg_riscv_vm_WasmVm as WasmVm, __wbg_init as default, __pkg_riscv_vm_initSync as initSync };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare function WasmInternal(): Promise<typeof __pkg_riscv_vm>;
|
|
126
|
+
|
|
127
|
+
export { WasmInternal };
|