Skip to content

Commit

Permalink
update to riscv-kernel-6.11.0 v17
Browse files Browse the repository at this point in the history
  • Loading branch information
ZLangJIT committed Oct 15, 2024
1 parent 6a821e1 commit 1614fe7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 82 deletions.
37 changes: 3 additions & 34 deletions apk_download.sh
Original file line number Diff line number Diff line change
@@ -1,43 +1,12 @@
IS_VERBOSE="-q"
while [[ $# -gt '0' ]]
do
if [[ "$1" == '-v' ]]
then
IS_VERBOSE="--show-progress -q"
shift
if [[ $# -gt '0' ]]
then
if [[ "$1" == '-v' ]]
then
IS_VERBOSE="--show-progress -v"
shift
fi
fi
else
if [[ "$1" == '--version_code' ]]
then
LIBMEDIA_GRADLE_VERSION_CODE="$2"
shift
shift
else
shift
fi
fi
done
if [[ -z $LIBMEDIA_GRADLE_VERSION_CODE ]]
then
. ./compute_libmedia_version.sh
fi
TAG=$LIBMEDIA_GRADLE_VERSION_CODE

. get_tag.sh $@
if $(am --help 2>&1 | grep -q -i "to-intent-uri")
then
echo "Android detected"
# prefer external application over termux shell
if $(pm list packages -3 2>&1 | grep -q "idm.internet.download.manager.plus")
then
echo "1DM+ detected"
am start --user 0 -n "idm.internet.download.manager.plus/idm.internet.download.manager.UrlHandlerDownloader" -d https://github.com/ZLangJIT/riscv-kernel/releases/download/$TAG/linux.kernel.rvvm.release.apk
am start --user 0 -n "idm.internet.download.manager.plus/idm.internet.download.manager.UrlHandlerDownloader" -d https://github.com/ZLangJIT/riscv-kernel/releases/download/$LIBMEDIA_GRADLE_VERSION_CODE/linux.kernel.rvvm.release.apk
exit
fi
if [[ -d /data/data/com.termux/files/usr ]]
Expand All @@ -48,7 +17,7 @@ if $(am --help 2>&1 | grep -q -i "to-intent-uri")
then
rm -v linux.kernel.rvvm.release.apk
fi
wget --no-verbose --show-progress https://github.com/ZLangJIT/riscv-kernel/releases/download/$TAG/linux.kernel.rvvm.release.apk &&
wget --no-verbose --show-progress https://github.com/ZLangJIT/riscv-kernel/releases/download/$LIBMEDIA_GRADLE_VERSION_CODE/linux.kernel.rvvm.release.apk &&
set +x &&
echo &&
echo 'please install the following apk ...' &&
Expand Down
41 changes: 41 additions & 0 deletions get_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
IS_VERBOSE="-q"
while [[ $# -gt '0' ]]
do
if [[ "$1" == '-v' ]]
then
IS_VERBOSE="--show-progress -q"
shift
if [[ $# -gt '0' ]]
then
if [[ "$1" == '-v' ]]
then
IS_VERBOSE="--show-progress -v"
shift
fi
fi
else
if [[ "$1" == '--version-code' ]]
then
LIBMEDIA_GRADLE_VERSION_CODE="$2"
shift
shift
else
if [[ "$1" == '-h' || "$1" == '--help' ]]
then
echo "usage:"
echo ""
echo " -h, --help this help text"
echo " -v print file download progress"
echo " -v -v print detailed file download progress"
echo " --version-code specify the version code, eg --version-code 17"
exit 1
else
shift
fi
fi
fi
done
if [[ -z $LIBMEDIA_GRADLE_VERSION_CODE ]]
then
. ./compute_libmedia_version.sh
fi
43 changes: 1 addition & 42 deletions push.sh
Original file line number Diff line number Diff line change
@@ -1,43 +1,2 @@
IS_VERBOSE="-q"
while [[ $# -gt '0' ]]
do
if [[ "$1" == '-v' ]]
then
IS_VERBOSE="--show-progress -q"
shift
if [[ $# -gt '0' ]]
then
if [[ "$1" == '-v' ]]
then
IS_VERBOSE="--show-progress -v"
shift
fi
fi
else
if [[ "$1" == '--version-code' ]]
then
LIBMEDIA_GRADLE_VERSION_CODE="$2"
shift
shift
else
if [[ "$1" == '-h' || "$1" == '--help' ]]
then
echo "usage:"
echo ""
echo " -h, --help this help text"
echo " -v print file download progress"
echo " -v -v print detailed file download progress"
echo " --version-code specify the version code, eg --version-code 17"
exit 1
else
shift
fi
fi
fi
done
if [[ -z $LIBMEDIA_GRADLE_VERSION_CODE ]]
then
. ./compute_libmedia_version.sh
fi

. get_tag.sh $@
git add -Av ; git commit -m "update to riscv-kernel-6.11.0 v$LIBMEDIA_GRADLE_VERSION_CODE" ; git log -n 1 ; git push
18 changes: 12 additions & 6 deletions rvvm.patch
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,10 @@ index 0000000..9ced2aa
+endif()
diff --git a/src/devices/shm.c b/src/devices/shm.c
new file mode 100644
index 0000000..3c56036
index 0000000..f248aab
--- /dev/null
+++ b/src/devices/shm.c
@@ -0,0 +1,177 @@
@@ -0,0 +1,183 @@
+/*
+shm.c - Memory-Mapped Shared Memory
+Copyright (C) 2024 ZLangJIT <github.com/ZLangJIT>
Expand All @@ -462,7 +462,7 @@ index 0000000..3c56036
+#include "fdtlib.h"
+#endif
+
+#if WIN32
+#if _WIN32
+
+#include <fileapi.h> // CreateFile
+#include <memoryapi.h> // MapViewOfFile, UnmapViewOfFile
Expand All @@ -482,7 +482,7 @@ index 0000000..3c56036
+static void shm_remove_file(rvvm_mmio_dev_t* device)
+{
+ shm_ctx_t* shm_ctx = (shm_ctx_t*)device->data;
+#if WIN32
+#if _WIN32
+ UnmapViewOfFile(shm_ctx->buffer);
+#else
+ munmap(shm_ctx->buffer, shm_ctx->size);
Expand Down Expand Up @@ -511,7 +511,7 @@ index 0000000..3c56036
+PUBLIC rvvm_mmio_dev_t* shm_init_data(rvvm_machine_t* machine, const char * path, const char * dev_name)
+{
+ shm_ctx_t* shm_ctx = safe_new_obj(shm_ctx_t);
+#if WIN32
+#if _WIN32
+ HANDLE file_handle = CreateFileA(path,
+ GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL
+ );
Expand All @@ -529,19 +529,22 @@ index 0000000..3c56036
+ int file_handle = open(path, O_RDONLY);
+ if (file_handle == -1) {
+ free(shm_ctx);
+ rvvm_info("Failed to map file %s (open() failed)", path);
+ return NULL;
+ }
+ struct stat file_info;
+ if (fstat(file_handle, &file_info) == -1) {
+ close(file_handle);
+ free(shm_ctx);
+ rvvm_info("Failed to map file %s (fstat() failed)", path);
+ return NULL;
+ }
+ shm_ctx->size = file_info.st_size;
+ shm_ctx->buffer = mmap(NULL, shm_ctx->size, PROT_READ, MAP_PRIVATE, file_handle, 0);
+ close(file_handle);
+ if (shm_ctx->buffer == MAP_FAILED) {
+ free(shm_ctx);
+ rvvm_info("Failed to map file %s (MAP_FAILED)", path);
+ return NULL;
+ }
+#endif
Expand All @@ -558,7 +561,7 @@ index 0000000..3c56036
+PUBLIC rvvm_mmio_dev_t* shm_init_exe(rvvm_machine_t* machine, const char * path, const char * dev_name)
+{
+ shm_ctx_t* shm_ctx = safe_new_obj(shm_ctx_t);
+#if WIN32
+#if _WIN32
+ HANDLE file_handle = CreateFileA(path,
+ GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL
+ );
Expand All @@ -575,19 +578,22 @@ index 0000000..3c56036
+ int file_handle = open(path, O_RDONLY);
+ if (file_handle == -1) {
+ free(shm_ctx);
+ rvvm_info("Failed to map file %s (open() failed)", path);
+ return NULL;
+ }
+ struct stat file_info;
+ if (fstat(file_handle, &file_info) == -1) {
+ close(file_handle);
+ free(shm_ctx);
+ rvvm_info("Failed to map file %s (fstat() failed)", path);
+ return NULL;
+ }
+ shm_ctx->size = file_info.st_size;
+ shm_ctx->buffer = mmap(NULL, shm_ctx->size, PROT_READ | PROT_EXEC, MAP_PRIVATE, file_handle, 0);
+ close(file_handle);
+ if (shm_ctx->buffer == MAP_FAILED) {
+ free(shm_ctx);
+ rvvm_info("Failed to map file %s (MAP_FAILED)", path);
+ return NULL;
+ }
+#endif
Expand Down

0 comments on commit 1614fe7

Please sign in to comment.