Skip to content

Commit 4a5d5d0

Browse files
author
Naveen Gogineni
committed
First commit
0 parents  commit 4a5d5d0

96 files changed

Lines changed: 37681 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Changelog

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2018-09-23:
2+
3+
- added support for separate RISC-V BIOS and kernel
4+
5+
2018-09-15:
6+
7+
- renamed to TinyEMU (temu)
8+
- single executable for all emulated machines
9+
10+
2018-08-29:
11+
12+
- compilation fixes
13+
14+
2017-08-06:
15+
16+
- added JSON configuration file
17+
- added graphical display with SDL
18+
- added VirtIO input support
19+
- added PCI bus and VirtIO PCI support
20+
- x86: added IDE, PS/2, vmmouse and VGA devices
21+
- added user mode network interface
22+
23+
2017-06-10:
24+
25+
- RISCV: avoid unnecessary kernel patches
26+
- x86: accept standard kernel images
27+
28+
2017-05-25:
29+
30+
- RISCV: faster emulation (1.4x)
31+
- Support of user level ISA version 2.2 and priviledged architecture
32+
version 1.10
33+
- added small x86 emulator (x86emu) based on KVM
34+
- modified the fs_net network protocol to match the vfsync protocol
35+
- handle console resize
36+
- JS emulator:
37+
- added scrollbar in terminal
38+
- added file import and export
39+
- added copy/paste support

MIT-LICENSE.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2016-2017 Fabrice Bellard
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

Makefile

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
#
2+
# TinyEMU
3+
#
4+
# Copyright (c) 2016-2018 Fabrice Bellard
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in
14+
# all copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
# THE SOFTWARE.
23+
#
24+
25+
# if set, network filesystem is enabled. libcurl and libcrypto
26+
# (openssl) must be installed.
27+
CONFIG_FS_NET=y
28+
# SDL support (optional)
29+
CONFIG_SDL=y
30+
# if set, compile the 128 bit emulator. Note: the 128 bit target does
31+
# not compile if gcc does not support the int128 type (32 bit hosts).
32+
CONFIG_INT128=y
33+
# build x86 emulator
34+
CONFIG_X86EMU=y
35+
# win32 build (not usable yet)
36+
#CONFIG_WIN32=y
37+
# user space network redirector
38+
CONFIG_SLIRP=y
39+
40+
ifdef CONFIG_WIN32
41+
CROSS_PREFIX=i686-w64-mingw32-
42+
EXE=.exe
43+
else
44+
CROSS_PREFIX=
45+
EXE=
46+
endif
47+
CC=$(CROSS_PREFIX)gcc
48+
STRIP=$(CROSS_PREFIX)strip
49+
CFLAGS=-O2 -Wall -g -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -MMD
50+
CFLAGS+=-D_GNU_SOURCE -DCONFIG_VERSION=\"$(shell cat VERSION)\"
51+
LDFLAGS=
52+
53+
bindir=/usr/local/bin
54+
INSTALL=install
55+
56+
PROGS+= temu$(EXE)
57+
ifndef CONFIG_WIN32
58+
ifdef CONFIG_FS_NET
59+
PROGS+=build_filelist splitimg
60+
endif
61+
endif
62+
63+
all: $(PROGS)
64+
65+
EMU_OBJS:=virtio.o pci.o fs.o cutils.o iomem.o simplefb.o \
66+
json.o machine.o temu.o
67+
68+
ifdef CONFIG_SLIRP
69+
CFLAGS+=-DCONFIG_SLIRP
70+
EMU_OBJS+=$(addprefix slirp/, bootp.o ip_icmp.o mbuf.o slirp.o tcp_output.o cksum.o ip_input.o misc.o socket.o tcp_subr.o udp.o if.o ip_output.o sbuf.o tcp_input.o tcp_timer.o)
71+
endif
72+
73+
ifndef CONFIG_WIN32
74+
EMU_OBJS+=fs_disk.o
75+
EMU_LIBS=-lrt
76+
endif
77+
ifdef CONFIG_FS_NET
78+
CFLAGS+=-DCONFIG_FS_NET
79+
EMU_OBJS+=fs_net.o fs_wget.o fs_utils.o block_net.o
80+
EMU_LIBS+=-lcurl -lcrypto
81+
ifdef CONFIG_WIN32
82+
EMU_LIBS+=-lwsock32
83+
endif # CONFIG_WIN32
84+
endif # CONFIG_FS_NET
85+
ifdef CONFIG_SDL
86+
EMU_LIBS+=-lSDL
87+
EMU_OBJS+=sdl.o
88+
CFLAGS+=-DCONFIG_SDL
89+
ifdef CONFIG_WIN32
90+
LDFLAGS+=-mwindows
91+
endif
92+
endif
93+
94+
EMU_OBJS+=riscv_machine.o softfp.o riscv_cpu32.o riscv_cpu64.o
95+
ifdef CONFIG_INT128
96+
CFLAGS+=-DCONFIG_RISCV_MAX_XLEN=128
97+
EMU_OBJS+=riscv_cpu128.o
98+
else
99+
CFLAGS+=-DCONFIG_RISCV_MAX_XLEN=64
100+
endif
101+
ifdef CONFIG_X86EMU
102+
EMU_OBJS+=x86_cpu.o x86_machine.o ide.o ps2.o vmmouse.o pckbd.o vga.o
103+
endif
104+
105+
temu$(EXE): $(EMU_OBJS)
106+
$(CC) $(LDFLAGS) -o $@ $^ $(EMU_LIBS)
107+
108+
riscv_cpu32.o: riscv_cpu.c
109+
$(CC) $(CFLAGS) -DMAX_XLEN=32 -c -o $@ $<
110+
111+
riscv_cpu64.o: riscv_cpu.c
112+
$(CC) $(CFLAGS) -DMAX_XLEN=64 -c -o $@ $<
113+
114+
riscv_cpu128.o: riscv_cpu.c
115+
$(CC) $(CFLAGS) -DMAX_XLEN=128 -c -o $@ $<
116+
117+
build_filelist: build_filelist.o fs_utils.o cutils.o
118+
$(CC) $(LDFLAGS) -o $@ $^ -lm
119+
120+
splitimg: splitimg.o
121+
$(CC) $(LDFLAGS) -o $@ $^
122+
123+
install: $(PROGS)
124+
$(STRIP) $(PROGS)
125+
$(INSTALL) -m755 $(PROGS) "$(DESTDIR)$(bindir)"
126+
127+
%.o: %.c
128+
$(CC) $(CFLAGS) -c -o $@ $<
129+
130+
clean:
131+
rm -f *.o *.d *~ $(PROGS) slirp/*.o slirp/*.d slirp/*~
132+
133+
-include $(wildcard *.d)
134+
-include $(wildcard slirp/*.d)

Makefile.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#
2+
# TinyEMU emulator
3+
#
4+
# Copyright (c) 2016-2018 Fabrice Bellard
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in
14+
# all copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
# THE SOFTWARE.
23+
#
24+
25+
# Build Javascript version of TinyEMU
26+
EMCC=emcc
27+
EMCFLAGS=-O2 --llvm-opts 2 -Wall -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -MMD -fno-strict-aliasing -DCONFIG_FS_NET
28+
#EMCFLAGS+=-Werror
29+
EMLDFLAGS=-O3 --memory-init-file 0 --closure 0 -s NO_EXIT_RUNTIME=1 -s NO_FILESYSTEM=1 -s "EXPORTED_FUNCTIONS=['_console_queue_char','_vm_start','_fs_import_file','_display_key_event','_display_mouse_event','_display_wheel_event','_net_write_packet','_net_set_carrier']" -s 'EXTRA_EXPORTED_RUNTIME_METHODS=["ccall", "cwrap"]' -s BINARYEN_TRAP_MODE=clamp --js-library js/lib.js
30+
EMLDFLAGS_ASMJS:=$(EMLDFLAGS) -s WASM=0
31+
EMLDFLAGS_WASM:=$(EMLDFLAGS) -s WASM=1 -s TOTAL_MEMORY=67108864 -s ALLOW_MEMORY_GROWTH=1
32+
33+
PROGS=js/riscvemu32.js js/riscvemu32-wasm.js js/riscvemu64.js js/riscvemu64-wasm.js
34+
35+
all: $(PROGS)
36+
37+
JS_OBJS=jsemu.js.o softfp.js.o virtio.js.o fs.js.o fs_net.js.o fs_wget.js.o fs_utils.js.o simplefb.js.o pci.js.o json.js.o block_net.js.o
38+
JS_OBJS+=iomem.js.o cutils.js.o aes.js.o sha256.js.o
39+
40+
RISCVEMU64_OBJS=$(JS_OBJS) riscv_cpu64.js.o riscv_machine.js.o machine_riscv.js.o
41+
RISCVEMU32_OBJS=$(JS_OBJS) riscv_cpu32.js.o riscv_machine.js.o machine_riscv.js.o
42+
43+
js/riscvemu64.js: $(RISCVEMU64_OBJS) js/lib.js
44+
$(EMCC) $(EMLDFLAGS_ASMJS) -o $@ $(RISCVEMU64_OBJS)
45+
46+
js/riscvemu32.js: $(RISCVEMU32_OBJS) js/lib.js
47+
$(EMCC) $(EMLDFLAGS_ASMJS) -o $@ $(RISCVEMU32_OBJS)
48+
49+
js/riscvemu64-wasm.js: $(RISCVEMU64_OBJS) js/lib.js
50+
$(EMCC) $(EMLDFLAGS_WASM) -o $@ $(RISCVEMU64_OBJS)
51+
52+
js/riscvemu32-wasm.js: $(RISCVEMU32_OBJS) js/lib.js
53+
$(EMCC) $(EMLDFLAGS_WASM) -o $@ $(RISCVEMU32_OBJS)
54+
55+
riscv_cpu32.js.o: riscv_cpu.c
56+
$(EMCC) $(EMCFLAGS) -DMAX_XLEN=32 -DCONFIG_RISCV_MAX_XLEN=32 -c -o $@ $<
57+
58+
riscv_cpu64.js.o: riscv_cpu.c
59+
$(EMCC) $(EMCFLAGS) -DMAX_XLEN=64 -DCONFIG_RISCV_MAX_XLEN=64 -c -o $@ $<
60+
61+
machine_riscv.js.o: machine.c
62+
$(EMCC) $(EMCFLAGS) -DCONFIG_RISCV_MACHINE -c -o $@ $<
63+
64+
65+
%.js.o: %.c
66+
$(EMCC) $(EMCFLAGS) -c -o $@ $<
67+
68+
-include $(wildcard *.d)

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2018-09-23

0 commit comments

Comments
 (0)