mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Update README.
Add license
This commit is contained in:
parent
789cd74516
commit
f8f7627eb8
3 changed files with 55 additions and 6 deletions
29
README.md
29
README.md
|
|
@ -4,6 +4,8 @@ uvm32 is a minimalist, dependency-free virtual machine sandbox designed for micr
|
||||||
|
|
||||||
On an [STM32L0](https://www.st.com/en/microcontrollers-microprocessors/stm32l0-series.html) (ARM Cortex-M0+) the required footprint is under 4KB flash/1KB RAM.
|
On an [STM32L0](https://www.st.com/en/microcontrollers-microprocessors/stm32l0-series.html) (ARM Cortex-M0+) the required footprint is under 4KB flash/1KB RAM.
|
||||||
|
|
||||||
|
uvm32 is a RISC-V emulator, wrapped in a management interface and provided with tools to build efficient code to run in it.
|
||||||
|
|
||||||
## What is it for?
|
## What is it for?
|
||||||
|
|
||||||
* As a no-frills alternative to embedded script engines ([Lua](https://www.lua.org/), [Duktape](https://duktape.org/), [MicroPython](https://micropython.org/), etc)
|
* As a no-frills alternative to embedded script engines ([Lua](https://www.lua.org/), [Duktape](https://duktape.org/), [MicroPython](https://micropython.org/), etc)
|
||||||
|
|
@ -11,6 +13,25 @@ On an [STM32L0](https://www.st.com/en/microcontrollers-microprocessors/stm32l0-s
|
||||||
* As a way to allow development in modern systems programming languages where a compiler for the target may not be available ([rust-hello](apps/rust-hello))
|
* As a way to allow development in modern systems programming languages where a compiler for the target may not be available ([rust-hello](apps/rust-hello))
|
||||||
* As a way to [write once, run anywhere](https://en.wikipedia.org/wiki/Write_once,_run_anywhere) and avoid maintaining multiple software variants
|
* As a way to [write once, run anywhere](https://en.wikipedia.org/wiki/Write_once,_run_anywhere) and avoid maintaining multiple software variants
|
||||||
|
|
||||||
|
## How does it compare to the alternatives?
|
||||||
|
|
||||||
|
Many scripting languages and virtual machines are available for embedding in small systems and they all make tradeoffs in different dimensions.
|
||||||
|
|
||||||
|
uvm32 aims for:
|
||||||
|
|
||||||
|
* Small footprint (suitable for embedded devices, games and apps)
|
||||||
|
* Support well-known programming languages for VM code (with high quality dev tools)
|
||||||
|
* Ease of integration into existing software
|
||||||
|
* Flexibility of paradigm (event driven, polling, multi-processor)
|
||||||
|
* Robustness against misbehaving VM code
|
||||||
|
|
||||||
|
uvm32 does not aim for:
|
||||||
|
|
||||||
|
* Frictionless [FFI](https://en.wikipedia.org/wiki/Foreign_function_interface) (no direct function calls between host and VM code)
|
||||||
|
* Maximum possible efficiency
|
||||||
|
* The simplest scripting experience for VM code (a develop-compile-run cycle is expected)
|
||||||
|
* "Batteries included" libraries to do stdio, networking, etc
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* Bytecode example apps written in C, Zig, Rust and assembly
|
* Bytecode example apps written in C, Zig, Rust and assembly
|
||||||
|
|
@ -29,7 +50,7 @@ uvm32 is a tiny virtual machine, all of the code is in [uvm32](uvm32).
|
||||||
|
|
||||||
A minimal example of a host to run code in is at [host-mini](hosts/host-mini).
|
A minimal example of a host to run code in is at [host-mini](hosts/host-mini).
|
||||||
|
|
||||||
Everything else is a more advanced host, or a sample application which could be run.
|
Everything else is a more advanced host example, or a sample application which could be run in a host.
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
|
|
@ -66,10 +87,10 @@ int main(int argc, char *argv[]) {
|
||||||
case UVM32_EVT_SYSCALL: // vm has paused to handle UVM32_SYSCALL
|
case UVM32_EVT_SYSCALL: // vm has paused to handle UVM32_SYSCALL
|
||||||
switch(evt.data.syscall.code) {
|
switch(evt.data.syscall.code) {
|
||||||
case UVM32_SYSCALL_PUTC:
|
case UVM32_SYSCALL_PUTC:
|
||||||
printf("%c", uvm32_getval(&vmst, &evt, ARG0));
|
printf("%c", uvm32_arg_getval(&vmst, &evt, ARG0));
|
||||||
break;
|
break;
|
||||||
case UVM32_SYSCALL_PRINTLN: {
|
case UVM32_SYSCALL_PRINTLN: {
|
||||||
const char *str = uvm32_getcstr(&vmst, &evt, ARG0);
|
const char *str = uvm32_arg_getcstr(&vmst, &evt, ARG0);
|
||||||
printf("%s\n", str);
|
printf("%s\n", str);
|
||||||
} break;
|
} break;
|
||||||
case UVM32_SYSCALL_YIELD:
|
case UVM32_SYSCALL_YIELD:
|
||||||
|
|
@ -120,6 +141,8 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
## Quickstart (docker)
|
## Quickstart (docker)
|
||||||
|
|
||||||
|
The code in [uvm32](uvm32) to build a VM host is very portable and requires only a C compiler. However, many of the examples provided show how to build target code with different languages and tools. A Dockerfile is provided to set up the required environment.
|
||||||
|
|
||||||
make dockerbuild
|
make dockerbuild
|
||||||
make dockershell
|
make dockershell
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,29 @@
|
||||||
|
/*!
|
||||||
|
https://github.com/ringtailsoftware/uvm32
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 Toby Jaffey <toby@ringtailsoftware.co.uk>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
#define MINIRV32_IMPLEMENTATION
|
#define MINIRV32_IMPLEMENTATION
|
||||||
#include "uvm32.h"
|
#include "uvm32.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
#ifndef UVM32_H
|
|
||||||
#define UVM32_H 1
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
https://github.com/ringtailsoftware/uvm32
|
https://github.com/ringtailsoftware/uvm32
|
||||||
|
|
||||||
|
|
@ -27,6 +24,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef UVM32_H
|
||||||
|
#define UVM32_H 1
|
||||||
|
|
||||||
/*! To use uvm32 in an environment without standard library headers, define CUSTOM_STDLIB_H to the name of header providing the equivalent types to stdint.h and stdbool.h */
|
/*! To use uvm32 in an environment without standard library headers, define CUSTOM_STDLIB_H to the name of header providing the equivalent types to stdint.h and stdbool.h */
|
||||||
#ifndef CUSTOM_STDLIB_H
|
#ifndef CUSTOM_STDLIB_H
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue