diff --git a/Makefile b/Makefile index e530de4..e94aa3f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ $(shell mkdir -p rootfsimg/build) -APPS = hello stream busybox redis dwarf/md5 dwarf/sort dwarf/wordcount +APPS = hello stream busybox redis dwarf/md5 dwarf/sort dwarf/wordcount new_before_workload after_workload APPS_DIR = $(addprefix apps/, $(APPS)) .PHONY: rootfsimg $(APPS_DIR) clean diff --git a/apps/after_workload/Makefile b/apps/after_workload/Makefile new file mode 100644 index 0000000..7d9daf8 --- /dev/null +++ b/apps/after_workload/Makefile @@ -0,0 +1,4 @@ +NAME = after_workload +SRCS = after_workload.c + +include $(RISCV_ROOTFS_HOME)/Makefile.compile diff --git a/apps/after_workload/after_workload.c b/apps/after_workload/after_workload.c new file mode 100644 index 0000000..adc981e --- /dev/null +++ b/apps/after_workload/after_workload.c @@ -0,0 +1,13 @@ +#include + +void nemu_signal(int op) +{ + asm volatile("mv a0, %0; .word 0x0000006b;"::"r"(op)); +} + + +int main(int argc, char const *argv[]) +{ + nemu_signal(0); + return 0; +} diff --git a/apps/busybox/Makefile b/apps/busybox/Makefile index b9bd47c..134bce8 100644 --- a/apps/busybox/Makefile +++ b/apps/busybox/Makefile @@ -5,7 +5,7 @@ include $(RISCV_ROOTFS_HOME)/Makefile.app REPO_PATH = repo $(REPO_PATH): mkdir -p $@ - git clone --depth 1 -b 1_29_stable git://git.busybox.net/busybox $@ + git clone --depth 1 -b 1_32_stable git://git.busybox.net/busybox $@ cp config $@/.config $(APP): | $(REPO_PATH) diff --git a/apps/busybox/config b/apps/busybox/config index c409384..a4de4b0 100644 --- a/apps/busybox/config +++ b/apps/busybox/config @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Busybox version: 1.29.3 -# Wed Nov 28 16:23:34 2018 +# Busybox version: 1.32.1 +# Tue Mar 29 15:57:59 2022 # CONFIG_HAVE_DOT_CONFIG=y @@ -24,6 +24,7 @@ CONFIG_FEATURE_WTMP=y CONFIG_FEATURE_PIDFILE=y CONFIG_PID_FILE_PATH="/var/run" CONFIG_BUSYBOX=y +CONFIG_FEATURE_SHOW_SCRIPT=y CONFIG_FEATURE_INSTALLER=y # CONFIG_INSTALL_NO_USR is not set CONFIG_FEATURE_SUID=y @@ -33,6 +34,7 @@ CONFIG_FEATURE_SUID_CONFIG_QUIET=y CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe" # CONFIG_SELINUX is not set # CONFIG_FEATURE_CLEAN_UP is not set +CONFIG_FEATURE_SYSLOG_INFO=y CONFIG_FEATURE_SYSLOG=y CONFIG_PLATFORM_LINUX=y @@ -74,6 +76,7 @@ CONFIG_PREFIX="./_install" # CONFIG_DEBUG_SANITIZE is not set # CONFIG_UNIT_TEST is not set # CONFIG_WERROR is not set +# CONFIG_WARN_SIMPLE_MSG is not set CONFIG_NO_DEBUG_LIB=y # CONFIG_DMALLOC is not set # CONFIG_EFENCE is not set @@ -82,7 +85,9 @@ CONFIG_NO_DEBUG_LIB=y # Library Tuning # # CONFIG_FEATURE_USE_BSS_TAIL is not set +CONFIG_FLOAT_DURATION=y CONFIG_FEATURE_RTMINMAX=y +CONFIG_FEATURE_RTMINMAX_USE_LIBC_DEFINITIONS=y CONFIG_FEATURE_BUFFERS_USE_MALLOC=y # CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set # CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set @@ -205,6 +210,7 @@ CONFIG_CKSUM=y CONFIG_COMM=y CONFIG_CP=y CONFIG_FEATURE_CP_LONG_OPTIONS=y +CONFIG_FEATURE_CP_REFLINK=y CONFIG_CUT=y CONFIG_DATE=y CONFIG_FEATURE_DATE_ISOFMT=y @@ -232,7 +238,6 @@ CONFIG_EXPR_MATH_SUPPORT_64=y CONFIG_FACTOR=y CONFIG_FALSE=y CONFIG_FOLD=y -CONFIG_FSYNC=y CONFIG_HEAD=y CONFIG_FEATURE_FANCY_HEAD=y CONFIG_HOSTID=y @@ -287,7 +292,6 @@ CONFIG_SHRED=y CONFIG_SHUF=y CONFIG_SLEEP=y CONFIG_FEATURE_FANCY_SLEEP=y -CONFIG_FEATURE_FLOAT_SLEEP=y CONFIG_SORT=y CONFIG_FEATURE_SORT_BIG=y # CONFIG_FEATURE_SORT_OPTIMIZE_MEMORY is not set @@ -300,6 +304,7 @@ CONFIG_STTY=y CONFIG_SUM=y CONFIG_SYNC=y CONFIG_FEATURE_SYNC_FANCY=y +CONFIG_FSYNC=y CONFIG_TAC=y CONFIG_TAIL=y CONFIG_FEATURE_FANCY_TAIL=y @@ -442,6 +447,7 @@ CONFIG_FEATURE_FIND_MTIME=y CONFIG_FEATURE_FIND_MMIN=y CONFIG_FEATURE_FIND_PERM=y CONFIG_FEATURE_FIND_TYPE=y +CONFIG_FEATURE_FIND_EXECUTABLE=y CONFIG_FEATURE_FIND_XDEV=y CONFIG_FEATURE_FIND_MAXDEPTH=y CONFIG_FEATURE_FIND_NEWER=y @@ -455,7 +461,9 @@ CONFIG_FEATURE_FIND_DEPTH=y CONFIG_FEATURE_FIND_PAREN=y CONFIG_FEATURE_FIND_SIZE=y CONFIG_FEATURE_FIND_PRUNE=y +CONFIG_FEATURE_FIND_QUIT=y CONFIG_FEATURE_FIND_DELETE=y +CONFIG_FEATURE_FIND_EMPTY=y CONFIG_FEATURE_FIND_PATH=y CONFIG_FEATURE_FIND_REGEX=y # CONFIG_FEATURE_FIND_CONTEXT is not set @@ -634,6 +642,7 @@ CONFIG_FEATURE_MDEV_RENAME=y CONFIG_FEATURE_MDEV_RENAME_REGEXP=y CONFIG_FEATURE_MDEV_EXEC=y CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y +CONFIG_FEATURE_MDEV_DAEMON=y CONFIG_MESG=y CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y CONFIG_MKE2FS=y @@ -657,6 +666,8 @@ CONFIG_FEATURE_MOUNT_FLAGS=y CONFIG_FEATURE_MOUNT_FSTAB=y CONFIG_FEATURE_MOUNT_OTHERTAB=y CONFIG_MOUNTPOINT=y +CONFIG_NOLOGIN=y +# CONFIG_NOLOGIN_DEPENDENCIES is not set CONFIG_NSENTER=y CONFIG_PIVOT_ROOT=y CONFIG_RDATE=y @@ -683,6 +694,7 @@ CONFIG_FEATURE_SWAPONOFF_LABEL=y CONFIG_SWITCH_ROOT=y CONFIG_TASKSET=y CONFIG_FEATURE_TASKSET_FANCY=y +CONFIG_FEATURE_TASKSET_CPULIST=y CONFIG_UEVENT=y CONFIG_UMOUNT=y CONFIG_FEATURE_UMOUNT_ALL=y @@ -732,6 +744,12 @@ CONFIG_FEATURE_VOLUMEID_XFS=y CONFIG_ADJTIMEX=y # CONFIG_BBCONFIG is not set # CONFIG_FEATURE_COMPRESS_BBCONFIG is not set +CONFIG_BC=y +CONFIG_DC=y +CONFIG_FEATURE_DC_BIG=y +# CONFIG_FEATURE_DC_LIBM is not set +CONFIG_FEATURE_BC_INTERACTIVE=y +CONFIG_FEATURE_BC_LONG_OPTIONS=y CONFIG_BEEP=y CONFIG_FEATURE_BEEP_FREQ=4000 CONFIG_FEATURE_BEEP_LENGTH_MS=30 @@ -750,8 +768,6 @@ CONFIG_FEATURE_CROND_CALL_SENDMAIL=y CONFIG_FEATURE_CROND_SPECIAL_TIMES=y CONFIG_FEATURE_CROND_DIR="/var/spool/cron" CONFIG_CRONTAB=y -CONFIG_DC=y -CONFIG_FEATURE_DC_LIBM=y # CONFIG_DEVFSD is not set # CONFIG_DEVFSD_MODLOAD is not set # CONFIG_DEVFSD_FG_NP is not set @@ -775,6 +791,7 @@ CONFIG_I2CGET=y CONFIG_I2CSET=y CONFIG_I2CDUMP=y CONFIG_I2CDETECT=y +CONFIG_I2CTRANSFER=y # CONFIG_INOTIFYD is not set CONFIG_LESS=y CONFIG_FEATURE_LESS_MAXLINES=9999999 @@ -795,6 +812,7 @@ CONFIG_MAKEDEVS=y CONFIG_FEATURE_MAKEDEVS_TABLE=y CONFIG_MAN=y CONFIG_MICROCOM=y +CONFIG_MIM=y CONFIG_MT=y CONFIG_NANDWRITE=y CONFIG_NANDDUMP=y @@ -808,6 +826,7 @@ CONFIG_SETFATTR=y CONFIG_SETSERIAL=y CONFIG_STRINGS=y CONFIG_TIME=y +CONFIG_TS=y CONFIG_TTYSIZE=y CONFIG_UBIATTACH=y CONFIG_UBIDETACH=y @@ -826,6 +845,7 @@ CONFIG_FEATURE_IPV6=y # CONFIG_FEATURE_UNIX_LOCAL is not set CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y # CONFIG_VERBOSE_RESOLUTION_ERRORS is not set +# CONFIG_FEATURE_TLS_SHA1 is not set CONFIG_ARP=y CONFIG_ARPING=y CONFIG_BRCTL=y @@ -913,6 +933,7 @@ CONFIG_FEATURE_NSLOOKUP_LONG_OPTIONS=y CONFIG_NTPD=y CONFIG_FEATURE_NTPD_SERVER=y CONFIG_FEATURE_NTPD_CONF=y +CONFIG_FEATURE_NTP_AUTH=y CONFIG_PING=y CONFIG_PING6=y CONFIG_FEATURE_FANCY_PING=y @@ -933,11 +954,8 @@ CONFIG_FEATURE_TELNETD_STANDALONE=y CONFIG_FEATURE_TELNETD_INETD_WAIT=y CONFIG_TFTP=y CONFIG_FEATURE_TFTP_PROGRESS_BAR=y +CONFIG_FEATURE_TFTP_HPA_COMPAT=y CONFIG_TFTPD=y - -# -# Common options for tftp/tftpd -# CONFIG_FEATURE_TFTP_GET=y CONFIG_FEATURE_TFTP_PUT=y CONFIG_FEATURE_TFTP_BLOCKSIZE=y @@ -1085,6 +1103,7 @@ CONFIG_SH_IS_ASH=y # CONFIG_BASH_IS_ASH is not set # CONFIG_BASH_IS_HUSH is not set CONFIG_BASH_IS_NONE=y +CONFIG_SHELL_ASH=y CONFIG_ASH=y CONFIG_ASH_OPTIMIZE_FOR_SIZE=y CONFIG_ASH_INTERNAL_GLOB=y @@ -1105,6 +1124,7 @@ CONFIG_ASH_GETOPTS=y CONFIG_ASH_CMDCMD=y CONFIG_CTTYHACK=y CONFIG_HUSH=y +CONFIG_SHELL_HUSH=y CONFIG_HUSH_BASH_COMPAT=y CONFIG_HUSH_BRACE_EXPANSION=y CONFIG_HUSH_LINENO_VAR=y @@ -1146,11 +1166,13 @@ CONFIG_HUSH_GETOPTS=y # CONFIG_FEATURE_SH_MATH=y CONFIG_FEATURE_SH_MATH_64=y +CONFIG_FEATURE_SH_MATH_BASE=y CONFIG_FEATURE_SH_EXTRA_QUIET=y # CONFIG_FEATURE_SH_STANDALONE is not set # CONFIG_FEATURE_SH_NOFORK is not set CONFIG_FEATURE_SH_READ_FRAC=y CONFIG_FEATURE_SH_HISTFILESIZE=y +CONFIG_FEATURE_SH_EMBEDDED_SCRIPTS=y # # System Logging Utilities @@ -1169,6 +1191,7 @@ CONFIG_FEATURE_ROTATE_LOGFILE=y CONFIG_FEATURE_REMOTE_LOG=y CONFIG_FEATURE_SYSLOGD_DUP=y CONFIG_FEATURE_SYSLOGD_CFG=y +# CONFIG_FEATURE_SYSLOGD_PRECISE_TIMESTAMPS is not set CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=256 CONFIG_FEATURE_IPC_SYSLOG=y CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=16 diff --git a/apps/new_before_workload/Makefile b/apps/new_before_workload/Makefile new file mode 100644 index 0000000..5004fec --- /dev/null +++ b/apps/new_before_workload/Makefile @@ -0,0 +1,4 @@ +NAME = new_before_workload +SRCS = new_before_workload.c + +include $(RISCV_ROOTFS_HOME)/Makefile.compile diff --git a/apps/new_before_workload/new_before_workload.c b/apps/new_before_workload/new_before_workload.c new file mode 100644 index 0000000..8933d68 --- /dev/null +++ b/apps/new_before_workload/new_before_workload.c @@ -0,0 +1,13 @@ +#include + +void nemu_signal(int op) +{ + asm volatile("mv a0, %0; .word 0x0000006b;"::"r"(op)); +} + + +int main(int argc, char const *argv[]) +{ + nemu_signal(257); + return 0; +} diff --git a/apps/redis/Makefile b/apps/redis/Makefile index 9b7f0de..80c4d9d 100644 --- a/apps/redis/Makefile +++ b/apps/redis/Makefile @@ -5,10 +5,10 @@ include $(RISCV_ROOTFS_HOME)/Makefile.app REPO_PATH = repo $(REPO_PATH): mkdir -p $@ - git clone --depth 1 -b 4.0.2 https://github.com/antirez/redis.git $@ + git clone -b 6.2.6 --depth 1 git@github.com:redis/redis.git $@ cd $@ && git apply ../riscv-cross-compile.patch $(APP): | $(REPO_PATH) - CROSS_COMPILE=riscv64-unknown-linux-gnu- $(MAKE) -C $(REPO_PATH) + $(MAKE) -C $(REPO_PATH) ln -sf $(abspath $(REPO_PATH)/src/$(NAME)) $@ riscv64-unknown-linux-gnu-strip $(abspath $(REPO_PATH)/src/$(NAME)) diff --git a/apps/redis/riscv-cross-compile.patch b/apps/redis/riscv-cross-compile.patch index d0d192c..07445ad 100644 --- a/apps/redis/riscv-cross-compile.patch +++ b/apps/redis/riscv-cross-compile.patch @@ -1,129 +1,40 @@ +From 377da6b9998e3fd6395b854999ab2531c54820ed Mon Sep 17 00:00:00 2001 +From: BigWhiteDog +Date: Tue, 29 Mar 2022 15:25:06 +0800 +Subject: [PATCH] a cross compile patch for riscv64 + +--- + Makefile | 2 +- + redis.conf | 6 +++--- + 2 files changed, 4 insertions(+), 4 deletions(-) + diff --git a/Makefile b/Makefile -index e614ede..a08a646 100644 +index e614ede..68f95dc 100644 --- a/Makefile +++ b/Makefile -@@ -3,6 +3,7 @@ +@@ -3,7 +3,7 @@ default: all .DEFAULT: -+ cd deps && $(MAKE) $@ - cd src && $(MAKE) $@ +- cd src && $(MAKE) $@ ++ cd src && $(MAKE) CC=riscv64-linux-gnu-gcc MALLOC=libc $@ install: -diff --git a/deps/Makefile b/deps/Makefile -index e148a33..c1d7c93 100644 ---- a/deps/Makefile -+++ b/deps/Makefile -@@ -39,7 +39,9 @@ distclean: - -(cd jemalloc && [ -f Makefile ] && $(MAKE) distclean) > /dev/null || true - -(rm -f .make-*) - --.PHONY: distclean -+clean: distclean -+ -+.PHONY: distclean clean - - hiredis: .make-prerequisites - @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) -@@ -77,7 +79,9 @@ JEMALLOC_LDFLAGS= $(LDFLAGS) - - jemalloc: .make-prerequisites - @printf '%b %b\n' $(MAKECOLOR)MAKE$(ENDCOLOR) $(BINCOLOR)$@$(ENDCOLOR) -- cd jemalloc && ./configure --with-lg-quantum=3 --with-jemalloc-prefix=je_ --enable-cc-silence CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" -+ cd jemalloc && ./configure --with-lg-quantum=3 --with-jemalloc-prefix=je_ --enable-cc-silence CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" --host=riscv64-unknown-linux-gnu - cd jemalloc && $(MAKE) CFLAGS="$(JEMALLOC_CFLAGS)" LDFLAGS="$(JEMALLOC_LDFLAGS)" lib/libjemalloc.a - -+all: hiredis linenoise lua jemalloc -+ - .PHONY: jemalloc -diff --git a/deps/hiredis/Makefile b/deps/hiredis/Makefile -index 9a4de83..8220277 100644 ---- a/deps/hiredis/Makefile -+++ b/deps/hiredis/Makefile -@@ -35,9 +35,9 @@ define REDIS_TEST_CONFIG - endef - export REDIS_TEST_CONFIG - --# Fallback to gcc when $CC is not in $PATH. --CC:=$(shell sh -c 'type $(CC) >/dev/null 2>/dev/null && echo $(CC) || echo gcc') --CXX:=$(shell sh -c 'type $(CXX) >/dev/null 2>/dev/null && echo $(CXX) || echo g++') -+CC := $(CROSS_COMPILE)gcc -+CXX:= $(CROSS_COMPILE)g++ -+ - OPTIMIZATION?=-O3 - WARNINGS=-Wall -W -Wstrict-prototypes -Wwrite-strings - DEBUG_FLAGS?= -g -ggdb -diff --git a/deps/linenoise/Makefile b/deps/linenoise/Makefile -index 1dd894b..27ad37b 100644 ---- a/deps/linenoise/Makefile -+++ b/deps/linenoise/Makefile -@@ -1,6 +1,9 @@ - STD= - WARN= -Wall - OPT= -Os -+CC:= $(CROSS_COMPILE)gcc -+CXX:= $(CROSS_COMPILE)g++ -+ - - R_CFLAGS= $(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) - R_LDFLAGS= $(LDFLAGS) -diff --git a/deps/lua/src/Makefile b/deps/lua/src/Makefile -index f3bba2f..3329187 100644 ---- a/deps/lua/src/Makefile -+++ b/deps/lua/src/Makefile -@@ -5,12 +5,14 @@ - # == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= - - # Your platform. See PLATS for possible values. --PLAT= none -+PLAT= ansi -+ -+CC:= $(CROSS_COMPILE)gcc -+CXX:= $(CROSS_COMPILE)g++ - --CC?= gcc - CFLAGS= -O2 -Wall $(MYCFLAGS) - AR= ar rcu --RANLIB= ranlib -+RANLIB= $(CROSS_COMPILE)ranlib - RM= rm -f - LIBS= -lm $(MYLIBS) - -@@ -92,7 +94,6 @@ bsd: - - freebsd: - $(MAKE) all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline" -- - generic: - $(MAKE) all MYCFLAGS= - -diff --git a/deps/lua/src/luaconf.h b/deps/lua/src/luaconf.h -index e2cb261..da2a7f4 100644 ---- a/deps/lua/src/luaconf.h -+++ b/deps/lua/src/luaconf.h -@@ -36,7 +36,7 @@ - #if defined(LUA_USE_LINUX) - #define LUA_USE_POSIX - #define LUA_USE_DLOPEN /* needs an extra library: -ldl */ --#define LUA_USE_READLINE /* needs some extra libraries */ -+//#define LUA_USE_READLINE /* needs some extra libraries */ - #endif - - #if defined(LUA_USE_MACOSX) + cd src && $(MAKE) $@ diff --git a/redis.conf b/redis.conf -index c54dba3..0b1c367 100644 +index e8eff27..f4d2c94 100644 --- a/redis.conf +++ b/redis.conf -@@ -66,7 +66,7 @@ +@@ -72,7 +72,7 @@ # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES - # JUST COMMENT THE FOLLOWING LINE. + # JUST COMMENT OUT THE FOLLOWING LINE. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --bind 127.0.0.1 -+#bind 127.0.0.1 +-bind 127.0.0.1 -::1 ++#bind 127.0.0.1 -::1 # Protected mode is a layer of security protection, in order to avoid that # Redis instances left open on the internet are accessed and exploited. -@@ -85,7 +85,7 @@ bind 127.0.0.1 +@@ -91,7 +91,7 @@ bind 127.0.0.1 -::1 # you are sure you want clients from other hosts to connect to Redis # even if no authentication is configured, nor a specific set of interfaces # are explicitly listed using the "bind" directive. @@ -132,38 +43,15 @@ index c54dba3..0b1c367 100644 # Accept connections on the specified port, default is 6379 (IANA #815344). # If port 0 is specified Redis will not listen on a TCP socket. -@@ -133,7 +133,7 @@ tcp-keepalive 300 - +@@ -254,7 +254,7 @@ tcp-keepalive 300 # By default Redis does not run as a daemon. Use 'yes' if you need it. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. + # When Redis is supervised by upstart or systemd, this parameter has no impact. -daemonize no +daemonize yes # If you run Redis from upstart or systemd, Redis can interact with your # supervision tree. Options: -@@ -215,9 +215,9 @@ always-show-logo yes - # - # save "" - --save 900 1 --save 300 10 --save 60 10000 -+#save 900 1 -+#save 300 10 -+#save 60 10000 - - # By default Redis will stop accepting writes if RDB snapshots are enabled - # (at least one save point) and the latest background save failed. -diff --git a/src/Makefile b/src/Makefile -index 86e0b3f..6a07920 100644 ---- a/src/Makefile -+++ b/src/Makefile -@@ -11,6 +11,8 @@ - # - # Dependencies are stored in the Makefile.dep file. To rebuild this file - # Just use 'make dep', but this is only needed by developers. -+CC:= $(CROSS_COMPILE)gcc -+CXX:= $(CROSS_COMPILE)g++ - - release_hdr := $(shell sh -c './mkreleasehdr.sh') - uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') +-- +2.35.1 + diff --git a/rootfsimg/.gitignore b/rootfsimg/.gitignore index 6591f7e..9a0b188 100644 --- a/rootfsimg/.gitignore +++ b/rootfsimg/.gitignore @@ -1,2 +1,5 @@ !initramfs*.txt !inittab +!inittab-spec +!spec_gen.py + diff --git a/rootfsimg/initramfs-autorun.txt b/rootfsimg/initramfs-autorun.txt index 400a3ab..c59e6e0 100644 --- a/rootfsimg/initramfs-autorun.txt +++ b/rootfsimg/initramfs-autorun.txt @@ -33,11 +33,17 @@ slink /init /bin/busybox 755 0 0 dir /root/benchmark 755 0 0 file /root/benchmark/stream ${RISCV_ROOTFS_HOME}/rootfsimg/build/stream 755 0 0 +file /root/new_before_workload ${RISCV_ROOTFS_HOME}/rootfsimg/build/new_before_workload 755 0 0 +file /root/after_workload ${RISCV_ROOTFS_HOME}/rootfsimg/build/after_workload 755 0 0 + # redis dir /root/redis 755 0 0 file /root/redis/redis-server ${RISCV_ROOTFS_HOME}/rootfsimg/build/redis-server 755 0 0 +file /root/redis/redis-cli ${RISCV_ROOTFS_HOME}/apps/redis/repo/src/redis-cli 755 0 0 file /root/redis/redis.conf ${RISCV_ROOTFS_HOME}/apps/redis/repo/redis.conf 644 0 0 file /root/redis/run-redis.sh ${RISCV_ROOTFS_HOME}/apps/redis/scripts/run-redis.sh 644 0 0 +file /root/redis/warmup-redis.cmd ${RISCV_ROOTFS_HOME}/rootfsimg/scripts/user-timeline-warmup-redis.cmd 444 0 0 +file /root/redis/run-redis.cmd ${RISCV_ROOTFS_HOME}/rootfsimg/scripts/user-timeline-run-redis.cmd 444 0 0 dir /etc/init.d 755 0 0 file /etc/init.d/rcS ${RISCV_ROOTFS_HOME}/rootfsimg/rcS 755 0 0 diff --git a/rootfsimg/inittab-spec b/rootfsimg/inittab-spec new file mode 100644 index 0000000..09d402d --- /dev/null +++ b/rootfsimg/inittab-spec @@ -0,0 +1,3 @@ +::sysinit:/bin/busybox --install -s +/dev/console::sysinit:-/bin/sh /spec/run.sh + diff --git a/rootfsimg/rcS b/rootfsimg/rcS index 751f4bf..bcb004e 100644 --- a/rootfsimg/rcS +++ b/rootfsimg/rcS @@ -3,6 +3,13 @@ pwd ls echo 12345 -/root/benchmark/stream -ifconfig -a -/root/redis/redis-server +ifconfig lo 127.0.0.1 +/root/redis/redis-server /root/redis/redis.conf +sleep 1 +ps -a +netstat -apnt +ifconfig +cat /root/redis/warmup-redis.cmd | /root/redis/redis-cli --pipe +/root/new_before_workload +cat /root/redis/run-redis.cmd | /root/redis/redis-cli --pipe +/root/after_workload diff --git a/rootfsimg/spec_gen.py b/rootfsimg/spec_gen.py new file mode 100644 index 0000000..04fbf16 --- /dev/null +++ b/rootfsimg/spec_gen.py @@ -0,0 +1,549 @@ +import os +import sys + +# (filelist, arguments) information for each benchmark +# filelist[0] should always be the binary file +spec_info = { + "astar_biglakes": ( + [ + "${SPEC}/spec06_exe/astar_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/astar/BigLakes2048.bin", + "${SPEC}/cpu2006_run_dir/astar/BigLakes2048.cfg" + ], + [ "BigLakes2048.cfg" ] + ), + "astar_rivers": ( + [ + "${SPEC}/spec06_exe/astar_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/astar/rivers.bin", + "${SPEC}/cpu2006_run_dir/astar/rivers.cfg" + ], + [ "rivers.cfg" ] + ), + "bwaves": ( + [ + "${SPEC}/spec06_exe/bwaves_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/bwaves/bwaves.in" + ], + [] + ), + "bzip2_chicken": ( + [ + "${SPEC}/spec06_exe/bzip2_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/bzip2/chicken.jpg" + ], + [ "chicken.jpg", "30" ] + ), + "bzip2_combined": ( + [ + "${SPEC}/spec06_exe/bzip2_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/bzip2/input.combined" + ], + [ "input.combined", "200" ] + ), + "bzip2_html": ( + [ + "${SPEC}/spec06_exe/bzip2_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/bzip2/text.html" + ], + [ "text.html", "280" ] + ), + "bzip2_liberty": ( + [ + "${SPEC}/spec06_exe/bzip2_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/bzip2/liberty.jpg" + ], + [ "liberty.jpg", "30" ] + ), + "bzip2_program": ( + [ + "${SPEC}/spec06_exe/bzip2_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/bzip2/input.program" + ], + [ "input.program", "280" ] + ), + "bzip2_source": ( + [ + "${SPEC}/spec06_exe/bzip2_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/bzip2/input.source" + ], + [ "input.source", "280" ] + ), + "cactusADM": ( + [ + "${SPEC}/spec06_exe/cactusADM_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/cactusADM/benchADM.par" + ], + [ "benchADM.par" ] + ), + "calculix": ( + [ + "${SPEC}/spec06_exe/calculix_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/calculix/hyperviscoplastic.dat", + "${SPEC}/cpu2006_run_dir/calculix/hyperviscoplastic.frd", + "${SPEC}/cpu2006_run_dir/calculix/hyperviscoplastic.inp", + "${SPEC}/cpu2006_run_dir/calculix/hyperviscoplastic.sta" + ], + [ "-i", "hyperviscoplastic" ] + ), + "dealII": ( + [ + "${SPEC}/spec06_exe/dealII_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/dealII/DummyData" + ], + [ "23" ] + ), + "gamess_cytosine": ( + [ + "${SPEC}/spec06_exe/gamess_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gamess/cytosine.2.config", + "${SPEC}/cpu2006_run_dir/gamess/cytosine.2.inp" + ], + [ "<", "cytosine.2.config" ] + ), + "gamess_gradient": ( + [ + "${SPEC}/spec06_exe/gamess_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gamess/h2ocu2+.gradient.config", + "${SPEC}/cpu2006_run_dir/gamess/h2ocu2+.gradient.inp" + ], + [ "<", "h2ocu2+.gradient.config" ] + ), + "gamess_triazolium": ( + [ + "${SPEC}/spec06_exe/gamess_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gamess/triazolium.config", + "${SPEC}/cpu2006_run_dir/gamess/triazolium.inp" + ], + [ "<", "triazolium.config" ] + ), + "gcc_166": ( + [ + "${SPEC}/spec06_exe/gcc_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gcc/166.i" + ], + [ "166.i", "-o", "166.s" ] + ), + "gcc_200": ( + [ + "${SPEC}/spec06_exe/gcc_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gcc/200.i" + ], + [ "200.i", "-o", "200.s" ] + ), + "gcc_cpdecl": ( + [ + "${SPEC}/spec06_exe/gcc_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gcc/cp-decl.i" + ], + [ "cp-decl.i", "-o", "cp-decl.s" ] + ), + "gcc_expr2": ( + [ + "${SPEC}/spec06_exe/gcc_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gcc/expr2.i" + ], + [ "expr2.i", "-o", "expr2.s" ] + ), + "gcc_expr": ( + [ + "${SPEC}/spec06_exe/gcc_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gcc/expr.i" + ], + [ "expr.i", "-o", "expr.s" ] + ), + "gcc_g23": ( + [ + "${SPEC}/spec06_exe/gcc_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gcc/g23.i" + ], + [ "g23.i", "-o", "g23.s" ] + ), + "gcc_s04": ( + [ + "${SPEC}/spec06_exe/gcc_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gcc/s04.i" + ], + [ "s04.i", "-o", "s04.s" ] + ), + "gcc_scilab": ( + [ + "${SPEC}/spec06_exe/gcc_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gcc/scilab.i" + ], + [ "scilab.i", "-o", "scilab.s" ] + ), + "gcc_typeck": ( + [ + "${SPEC}/spec06_exe/gcc_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gcc/c-typeck.i" + ], + [ "c-typeck.i", "-o", "c-typeck.s" ] + ), + "GemsFDTD": ( + [ + "${SPEC}/spec06_exe/GemsFDTD_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/GemsFDTD/ref.in", + "${SPEC}/cpu2006_run_dir/GemsFDTD/sphere.pec", + "${SPEC}/cpu2006_run_dir/GemsFDTD/yee.dat" + ], + [] + ), + "gobmk_13x13": ( + [ + "${SPEC}/spec06_exe/gobmk_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gobmk/13x13.tst", + "dir games /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/gobmk/games", + "dir golois /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/gobmk/golois" + ], + [ "--quiet", "--mode", "gtp", "<", "13x13.tst" ] + ), + "gobmk_nngs": ( + [ + "${SPEC}/spec06_exe/gobmk_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gobmk/nngs.tst", + "dir games /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/gobmk/games", + "dir golois /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/gobmk/golois" + ], + [ "--quiet", "--mode", "gtp", "<", "nngs.tst" ] + ), + "gobmk_score2": ( + [ + "${SPEC}/spec06_exe/gobmk_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gobmk/score2.tst", + "dir games /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/gobmk/games", + "dir golois /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/gobmk/golois" + ], + [ "--quiet", "--mode", "gtp", "<", "score2.tst" ] + ), + "gobmk_trevorc": ( + [ + "${SPEC}/spec06_exe/gobmk_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gobmk/trevorc.tst", + "dir games /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/gobmk/games", + "dir golois /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/gobmk/golois" + ], + [ "--quiet", "--mode", "gtp", "<", "trevorc.tst" ] + ), + "gobmk_trevord": ( + [ + "${SPEC}/spec06_exe/gobmk_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gobmk/trevord.tst", + "dir games /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/gobmk/games", + "dir golois /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/gobmk/golois" + ], + [ "--quiet", "--mode", "gtp", "<", "trevord.tst" ] + ), + "gromacs": ( + [ + "${SPEC}/spec06_exe/gromacs_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gromacs/gromacs.tpr" + ], + [ "-silent", "-deffnm", "gromacs.tpr", "-nice", "0" ] + ), + "h264ref_foreman.baseline": ( + [ + "${SPEC}/spec06_exe/h264ref_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/h264ref/foreman_ref_encoder_baseline.cfg", + "${SPEC}/cpu2006_run_dir/h264ref/foreman_qcif.yuv" + ], + [ "-d", "foreman_ref_encoder_baseline.cfg" ] + ), + "h264ref_foreman.main": ( + [ + "${SPEC}/spec06_exe/h264ref_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/h264ref/foreman_ref_encoder_main.cfg", + "${SPEC}/cpu2006_run_dir/h264ref/foreman_qcif.yuv" + ], + [ "-d", "foreman_ref_encoder_main.cfg" ] + ), + "h264ref_sss": ( + [ + "${SPEC}/spec06_exe/h264ref_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/h264ref/sss_encoder_main.cfg", + "${SPEC}/cpu2006_run_dir/h264ref/sss.yuv" + ], + [ "-d", "sss_encoder_main.cfg" ] + ), + "hmmer_nph3": ( + [ + "${SPEC}/spec06_exe/hmmer_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/hmmer/nph3.hmm", + "${SPEC}/cpu2006_run_dir/hmmer/swiss41" + ], + [ "nph3.hmm", "swiss41" ] + ), + "hmmer_retro": ( + [ + "${SPEC}/spec06_exe/hmmer_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/hmmer/retro.hmm" + ], + [ "--fixed", "0", "--mean", "500", "--num", "500000", "--sd", "350", "--seed", "0", "retro.hmm" ] + ), + "lbm": ( + [ + "${SPEC}/spec06_exe/lbm_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/lbm/100_100_130_ldc.of", + "${SPEC}/cpu2006_run_dir/lbm/lbm.in" + ], + [ "3000", "reference.dat", "0", "0", "100_100_130_ldc.of" ] + ), + "leslie3d": ( + [ + "${SPEC}/spec06_exe/leslie3d_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/leslie3d/leslie3d.in" + ], + [ "<", "leslie3d.in" ] + ), + "libquantum": ( + [ + "${SPEC}/spec06_exe/libquantum_base.riscv64-linux-gnu-gcc-9.3.0" + ], + [ "1397", "8" ] + ), + "mcf": ( + [ + "${SPEC}/spec06_exe/mcf_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/mcf/inp.in" + ], + [ "inp.in" ] + ), + "milc": ( + [ + "${SPEC}/spec06_exe/milc_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/milc/su3imp.in" + ], + [ "<", "su3imp.in" ] + ), + "namd": ( + [ + "${SPEC}/spec06_exe/namd_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/namd/namd.input" + ], + [ "--input", "namd.input", "--iterations", "38", "--output", "namd.out" ] + ), + "omnetpp": ( + [ + "${SPEC}/spec06_exe/omnetpp_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/omnetpp/omnetpp.ini" + ], + [ "omnetpp.ini" ] + ), + "perlbench_checkspam": ( + [ + "${SPEC}/spec06_exe/perlbench_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/perlbench/cpu2006_mhonarc.rc", + "${SPEC}/cpu2006_run_dir/perlbench/checkspam.pl", + "${SPEC}/cpu2006_run_dir/perlbench/checkspam.in", + "dir lib /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/perlbench/lib", + "dir rules /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/perlbench/rules" + ], + [ "-I./lib", "checkspam.pl", "2500", "5", "25", "11", "150", "1", "1", "1", "1" ] + ), + "perlbench_diffmail": ( + [ + "${SPEC}/spec06_exe/perlbench_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/perlbench/cpu2006_mhonarc.rc", + "${SPEC}/cpu2006_run_dir/perlbench/diffmail.pl", + "${SPEC}/cpu2006_run_dir/perlbench/diffmail.in", + "dir lib /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/perlbench/lib", + "dir rules /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/perlbench/rules" + ], + [ "-I./lib", "diffmail.pl", "4", "800", "10", "17", "19", "300" ] + ), + "perlbench_splitmail": ( + [ + "${SPEC}/spec06_exe/perlbench_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/perlbench/cpu2006_mhonarc.rc", + "${SPEC}/cpu2006_run_dir/perlbench/splitmail.pl", + "${SPEC}/cpu2006_run_dir/perlbench/splitmail.in", + "dir lib /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/perlbench/lib", + "dir rules /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/perlbench/rules" + ], + [ "-I./lib", "splitmail.pl", "1600", "12", "26", "16", "4500" ] + ), + "povray": ( + [ + "${SPEC}/spec06_exe/povray_base.riscv64-linux-gnu-gcc-9.3.0", + "dir . /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/povray" + ], + [ "SPEC-benchmark-ref.ini" ] + ), + "sjeng": ( + [ + "${SPEC}/spec06_exe/sjeng_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/sjeng/ref.txt" + ], + [ "ref.txt" ] + ), + "soplex_pds-50": ( + [ + "${SPEC}/spec06_exe/soplex_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/soplex/pds-50.mps" + ], + [ "-s1", "-e", "-m45000", "pds-50.mps" ] + ), + "soplex_ref": ( + [ + "${SPEC}/spec06_exe/soplex_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/soplex/ref.mps" + ], + [ "-m3500", "ref.mps" ] + ), + "sphinx3": ( + [ + "${SPEC}/spec06_exe/sphinx_livepretend_base.riscv64-linux-gnu-gcc-9.3.0", + "dir . /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/sphinx3" + ], + [ "ctlfile", ".", "args.an4" ] + ), + "tonto": ( + [ + "${SPEC}/spec06_exe/tonto_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/tonto/stdin" + ], + [] + ), + "wrf": ( + [ + "${SPEC}/spec06_exe/wrf_base.riscv64-linux-gnu-gcc-9.3.0", + "dir . /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/wrf" + ], + [] + ), + "xalancbmk": ( + [ + "${SPEC}/spec06_exe/Xalan_base.riscv64-linux-gnu-gcc-9.3.0", + "dir . /bigdata/xs-workloads/spec/spec-all/cpu2006_run_dir/xalancbmk" + ], + [ "-v", "t5.xml", "xalanc.xsl" ] + ), + "zeusmp": ( + [ + "${SPEC}/spec06_exe/zeusmp_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/zeusmp/zmp_inp" + ], + [] + ), + # WARNING: this is SPEC test + "gamess_exam29": ( + [ + "${SPEC}/spec06_exe/gamess_base.riscv64-linux-gnu-gcc-9.3.0", + "${SPEC}/cpu2006_run_dir/gamess/exam29.config", + "${SPEC}/cpu2006_run_dir/gamess/exam29.inp" + ], + [ "<", "exam29.config" ] + ), +} + +default_files = [ + "dir /bin 755 0 0", + "dir /etc 755 0 0", + "dir /dev 755 0 0", + "dir /lib 755 0 0", + "dir /proc 755 0 0", + "dir /sbin 755 0 0", + "dir /sys 755 0 0", + "dir /tmp 755 0 0", + "dir /usr 755 0 0", + "dir /mnt 755 0 0", + "dir /usr/bin 755 0 0", + "dir /usr/lib 755 0 0", + "dir /usr/sbin 755 0 0", + "dir /var 755 0 0", + "dir /var/tmp 755 0 0", + "dir /root 755 0 0", + "dir /var/log 755 0 0", + "", + "nod /dev/console 644 0 0 c 5 1", + "nod /dev/null 644 0 0 c 1 3", + "", + "# libraries", + "file /lib/ld-linux-riscv64-lp64d.so.1 ${RISCV}/sysroot/lib/ld-linux-riscv64-lp64d.so.1 755 0 0", + "file /lib/libc.so.6 ${RISCV}/sysroot/lib/libc.so.6 755 0 0", + "file /lib/libresolv.so.2 ${RISCV}/sysroot/lib/libresolv.so.2 755 0 0", + "file /lib/libm.so.6 ${RISCV}/sysroot/lib/libm.so.6 755 0 0", + "file /lib/libdl.so.2 ${RISCV}/sysroot/lib/libdl.so.2 755 0 0", + "file /lib/libpthread.so.0 ${RISCV}/sysroot/lib/libpthread.so.0 755 0 0", + "", + "# busybox", + "file /bin/busybox ${RISCV_ROOTFS_HOME}/rootfsimg/build/busybox 755 0 0", + "file /etc/inittab ${RISCV_ROOTFS_HOME}/rootfsimg/inittab-spec 755 0 0", + "slink /init /bin/busybox 755 0 0", + "", + "# SPEC common", + "dir /spec_common 755 0 0", + "file /spec_common/before_workload ${SPEC}/before_workload 755 0 0", + "file /spec_common/trap ${SPEC}/trap_new 755 0 0", + "", + "# SPEC", + "dir /spec 755 0 0", + "file /spec/run.sh ${RISCV_ROOTFS_HOME}/rootfsimg/run.sh 755 0 0" +] + +def traverse_path(path, stack=""): + all_dirs, all_files = [], [] + for item in os.listdir(path): + item_path = os.path.join(path, item) + item_stack = os.path.join(stack, item) + if os.path.isfile(item_path): + all_files.append(item_stack) + else: + all_dirs.append(item_stack) + sub_dirs, sub_files = traverse_path(item_path, item_stack) + all_dirs.extend(sub_dirs) + all_files.extend(sub_files) + return (all_dirs, all_files) + +def generate_initramfs(specs): + lines = default_files.copy() + for spec in specs: + spec_files = spec_info[spec][0] + for i, filename in enumerate(spec_files): + if len(filename.split()) == 1: + # print(f"default {filename} to file 755 0 0") + basename = filename.split("/")[-1] + filename = f"file /spec/{basename} {filename} 755 0 0" + lines.append(filename) + elif len(filename.split()) == 3: + node_type, name, path = filename.split() + if node_type != "dir": + print(f"unknown filename: {filename}") + continue + all_dirs, all_files = traverse_path(path) + lines.append(f"dir /spec/{name} 755 0 0") + for sub_dir in all_dirs: + lines.append(f"dir /spec/{name}/{sub_dir} 755 0 0") + for file in all_files: + lines.append(f"file /spec/{name}/{file} {path}/{file} 755 0 0") + else: + print(f"unknown filename: {filename}") + with open("initramfs-spec.txt", "w") as f: + f.writelines(map(lambda x: x + "\n", lines)) + + +def generate_run_sh(specs, withTrap=False): + lines =[ ] + lines.append("#!/bin/sh") + lines.append("echo '===== Start running SPEC2006 ====='") + for spec in specs: + spec_bin = spec_info[spec][0][0].split("/")[-1] + spec_cmd = " ".join(spec_info[spec][1]) + lines.append(f"echo '======== BEGIN {spec} ========'") + lines.append("set -x") + lines.append(f"md5sum /spec/{spec_bin}") + lines.append("date -R") + lines.append(f"cd /spec && ./{spec_bin} {spec_cmd}") + lines.append("date -R") + lines.append("set +x") + lines.append(f"echo '======== END {spec} ========'") + lines.append("echo '===== Finish running SPEC2006 ====='") + if withTrap: + lines.append("/spec_common/trap") + with open("run.sh", "w") as f: + f.writelines(map(lambda x: x + "\n", lines)) + +if __name__ == "__main__": + specs = sys.argv[1:] + generate_initramfs(specs) + generate_run_sh(specs, True)