-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dorian Eikenberg
committed
Jan 21, 2020
1 parent
0956964
commit 967db34
Showing
3 changed files
with
45 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
CC = gcc | ||
CFLAGS = -lmicrovmi -L../target/debug | ||
CWD := $(shell pwd) | ||
|
||
.PHONY: all clean | ||
|
||
all: mem-dump pause regs-dump | ||
|
||
libmicrovmi.h: ../target/debug/libmicrovmi.so | ||
cd ..; \ | ||
cbindgen --config cbindgen.toml --crate microvmi --output "${CWD}/libmicrovmi.h" | ||
|
||
mem-dump: libmicrovmi.h mem-dump.c | ||
$(CC) $(CFLAGS) -o mem-dump mem-dump.c | ||
|
||
pause: libmicrovmi.h pause.c | ||
$(CC) $(CFLAGS) -o pause pause.c | ||
|
||
regs-dump: libmicrovmi.h regs-dump.c | ||
$(CC) $(CFLAGS) -o regs-dump regs-dump.c | ||
|
||
clean: | ||
rm -f libmicrovmi.h mem-dump pause regs-dump |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# C Interoperability | ||
|
||
It is possible to call *libmicrovmi* functions from C code. To this end, a header file has to be generated. | ||
This requires the `cbindgen` tool which can be installed via the following command: | ||
|
||
~~~ | ||
cargo install --force cbindgen | ||
~~~ | ||
|
||
## Building the examples | ||
|
||
To build the examples just use the makefile located in `c_examples`. | ||
It will also generate the header file for you provided you have installed cbindgen. | ||
You just have to make sure that you have already built *libmicrovmi*. | ||
|
||
## Executing the examples | ||
|
||
Command to execute an example as an unprivileged user: | ||
|
||
~~~ | ||
sudo LD_LIBRARY_PATH="$LD_LIBRARY_PATH:../target/debug" <example> <vm_name> | ||
~~~ |