-
Notifications
You must be signed in to change notification settings - Fork 27
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
1 parent
2435903
commit fb8a9bf
Showing
11 changed files
with
2,527 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#ifdef __riscv | ||
|
||
#define riscv_roi_begin() asm volatile("csrwi 0x801, 1") | ||
#define riscv_roi_end() asm volatile("csrwi 0x801, 0") | ||
#define riscv_terminate() asm volatile("csrwi 0x800, 0") | ||
|
||
#else | ||
|
||
#define riscv_roi_begin() | ||
#define riscv_roi_end() | ||
#define riscv_terminate() | ||
|
||
#endif |
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,2 @@ | ||
terminate | ||
terminate.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,6 @@ | ||
PREFIX = riscv64-unknown-linux-gnu | ||
TARGET = terminate | ||
|
||
all: | ||
$(PREFIX)-g++ -I.. -static main.cpp -o $(TARGET) | ||
$(PREFIX)-objdump -d $(TARGET) > $(TARGET).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,7 @@ | ||
#include "riscv_custom.h" | ||
|
||
int main() { | ||
riscv_terminate(); | ||
while(1); | ||
return 0; | ||
} |
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 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [ $# -ne 0 ]; then | ||
JOBS=$1 | ||
else | ||
JOBS=1 | ||
fi | ||
|
||
CURDIR=`pwd` | ||
|
||
cd RV64G | ||
rm -rf busybox* | ||
wget https://busybox.net/downloads/busybox-1.21.1.tar.bz2 | ||
tar -xf busybox-1.21.1.tar.bz2 | ||
cd busybox-1.21.1 | ||
cp $CURDIR/configs/busybox_config .config | ||
make -j$JOBS | ||
|
||
cd $CURDIR | ||
echo "busybox compiled successfully" |
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,61 @@ | ||
#!/usr/bin/python | ||
|
||
import os | ||
import stat | ||
import shutil | ||
import argparse | ||
import subprocess | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--testdir', dest = 'test_dir', | ||
required = False, default = '') | ||
parser.add_argument('--jobs', dest = 'jobs', required = False, default = 1) | ||
args = parser.parse_args() | ||
|
||
root = os.path.join(os.environ['RISCY_HOME'], 'tools') | ||
linux_dir = os.path.join(root, 'riscv-linux') | ||
config_dir = os.path.join(root, 'configs') | ||
build_dir = os.environ['RISCY_TOOLS'] | ||
test_dir = '' if args.test_dir == '' else os.path.abspath(args.test_dir) | ||
|
||
# copy initramfs.txt and .config | ||
shutil.copy(os.path.join(config_dir, 'linux_config'), | ||
os.path.join(linux_dir, '.config')) | ||
shutil.copy(os.path.join(config_dir, 'initramfs.txt'), linux_dir) | ||
|
||
# append to initramfs.txt with contents in test folder | ||
if test_dir != '': | ||
with open(os.path.join(linux_dir, 'initramfs.txt'), 'a') as fp: | ||
def writeTree(ramfs_dir, src_dir): | ||
for f in os.listdir(src_dir): | ||
ramfs_path = os.path.join(ramfs_dir, f) | ||
src_path = os.path.join(src_dir, f) | ||
mode = os.stat(src_path).st_mode | ||
perm = oct(stat.S_IMODE(mode))[-3:] | ||
if stat.S_ISDIR(mode): | ||
fp.write('dir {} {} 0 0\n'.format(ramfs_path, perm)) | ||
writeTree(ramfs_path, src_path) | ||
elif stat.S_ISREG(mode): | ||
fp.write('file {} {} {} 0 0\n'.format(ramfs_path, | ||
src_path, | ||
perm)) | ||
else: | ||
raise Exception('unknown file type ' + src_path) | ||
writeTree('/test', test_dir) | ||
|
||
# compile vmlinux | ||
cmd = 'cd {}; make ARCH=riscv -j{}'.format(linux_dir, args.jobs) | ||
print 'Running: {}'.format(cmd) | ||
subprocess.check_call(cmd, shell = True) | ||
|
||
# compile bbl | ||
cmd = ('cd {}; '.format(build_dir) + | ||
'rm -rf build-pk; mkdir -p build-pk; cd build-pk; ' + | ||
'../../riscv-pk/configure ' + | ||
'--prefix={} '.format(build_dir) + | ||
'--host=riscv64-unknown-linux-gnu ' + | ||
'--with-payload={}; '.format(os.path.join(linux_dir, 'vmlinux')) + | ||
'make -j{}; make install'.format(args.jobs)) | ||
print 'Running: {}'.format(cmd) | ||
subprocess.check_call(cmd, shell = True) | ||
|
Oops, something went wrong.