From 43fec42a5ea8bced7f5631f1b9404580d590f14b Mon Sep 17 00:00:00 2001 From: Abdalla Date: Thu, 22 Aug 2024 13:35:49 +0200 Subject: [PATCH] feat: change for arm to use clcok_gettime --- installation_procedure.txt | 3 ++- src/backend/arm_backend/arm_backend.py | 7 ++++--- src/backend/generate_executable.py | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/installation_procedure.txt b/installation_procedure.txt index 5dd33a1..01331dd 100644 --- a/installation_procedure.txt +++ b/installation_procedure.txt @@ -1,7 +1,7 @@ Reminder: this is for linux setup 1. Install flexpret by following it's instructions. Use branch gametime-support. Can use instructions of master branch. - ***Remember to export PATH=$PATH:/home/c/Desktop/research/lf/code/flexpret/emulator*** USE ABS PATH + ***Remember to export PATH=$PATH:/Users/abdallaeltayeb/Desktop/Gamtime_project/flexpret/emulator*** USE ABS PATH export PATH=$PATH:/opt/riscv/bin 2. Pull the lastest Gametime. @@ -30,3 +30,4 @@ apt-get install -qqy --no-install-recommends \ 7. Install KLEE and pycparser. Place pycparser in same directory as gametime to ensure it can find the stubs. 7. To regenerate documentation: install sphinx and numpydoc. Then run: make html; sphinx-build -b html ./ build/ -v +export PATH="/opt/homebrew/opt/llvm@14/bin:$PATH" \ No newline at end of file diff --git a/src/backend/arm_backend/arm_backend.py b/src/backend/arm_backend/arm_backend.py index d94daf0..afcbe07 100644 --- a/src/backend/arm_backend/arm_backend.py +++ b/src/backend/arm_backend/arm_backend.py @@ -13,9 +13,10 @@ class ArmBackend(Backend): timing_func = """ static inline unsigned long long read_cycle_count() { - unsigned long long val; - asm volatile("mrs %0, PMCCNTR_EL0" : "=r" (val)); - return val; + struct timespec time; + clock_gettime(CLOCK_MONOTONIC, &time); + unsigned long long nanoTime = time.tv_sec * 1000000000L + time.tv_nsec; + return nanoTime; } """ diff --git a/src/backend/generate_executable.py b/src/backend/generate_executable.py index 0e29a5b..d64cba3 100644 --- a/src/backend/generate_executable.py +++ b/src/backend/generate_executable.py @@ -427,7 +427,9 @@ def generate_executable(input_file, input_folder, function_name, hex_values_file # This must be included in we want to run flexpret backend (for printf) if include_flexpret: - original_c_content = "#include \n" + original_c_content + original_c_content = "#include \n" + original_c_content + else: + original_c_content = "#include \n" + original_c_content #TODO: generate global variables, add the global timing function original_c_content += timing_function_body