mcips plugin: Sync time between qemu and systemC#62
Open
alwalidsalama wants to merge 13 commits into
Open
Conversation
Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
Introduce the PluginAPI class to expose QEMU's TCG Plugin API for SystemC-based plugin modeling at the Qbox level. - Add tcg_plugin_api.h: Define PluginAPI class with function pointers for all TCG Plugin API functions - Add tcg_plugin_api.cc: Implement bind_qemu_plugin_symbols() to dynamically link TCG Plugin function symbols from libqemu - Redeclare key TCG Plugin structs, enums, typedefs, and macros required for plugin development - Update CMakeLists.txt: Add tcg_plugin_api.cc to qemu_srcs build list Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
Complete the TCG Plugin API integration by connecting PluginAPI to the main LibQemu class, enabling plugin functionality throughout Qbox. - Add plugin_api member to qemu::LibQemu class (libqemu-cxx.h) - Include tcg_plugin_api.h header in libqemu-cxx.h - Initialize plugin_api during LibQemu::init() by calling bind_qemu_plugin_symbols() with the loaded library handle - This makes the TCG Plugin API accessible to all Qbox components through the LibQemu instance Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
- add attach(), detach() and is_attached() helper functions for sync_window - Add m_is_attached flag to track attach/detach state and validate async_set_window() calls. Fatal error if called while detached. Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
Introduce LibQemuPlugin, a SystemC module that provides a C++ interface for QEMU's TCG (Tiny Code Generator) plugin API. This base class enables seamless integration between QEMU's C-based plugin system and QBox's C++ SystemC components. - Retrieve and manage QEMU plugin ID through the 'key' parameter mechanism - Provide macros (REGISTER_CALLBACK_ID and REGISTER_CALLBACK_USERDATA) to bridge C callbacks with C++ member functions using acquire/release instance pattern for thread-safe callback routing - Maintain a heap-allocated id_map (outlives main()) protected by a shared_mutex to associate QEMU plugin IDs with LibQemuPlugin instances - Use refcount-based shutdown_bridge() to drain in-flight callbacks before destruction - Allow derived classes to override virtual callback methods - Include enable_* methods for each callback type to register with QEMU - Support both ID-based and userdata-based callback patterns - Add libqemu-plugin.cc to CMakeLists.txt build sources Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
Implement McipsPlugin (Multi Core Instruction Per Second Plugin), a plugin which provides instruction-based performance simulation and time synchronization between QEMU and SystemC. - Track executed instructions per vCPU using QEMU's scoreboard API - Trigger vcpu_tb_exec_cond when instruction count reaches quantum threshold for each vCPU - Compute vCPU time based on instruction count and configurable instructions-per-second rate - Track which CPU is advancing QEMU's global time (active CPU) - Keep all vCPUs within a quantum window to prevent time drift - Implement get_qemu_clock() to provide time to QEMU (based on active CPU's time) - Use sc_sync_window with TLM quantum policy to coordinate with SystemC - Manage vCPU states (IDLE, RUNNING, PAUSED) - Pause CPUs that advance too far ahead via pause_if_ahead() - Resume CPUs that fall behind via resume_if_behind() - Centralize scheduling decisions in rebalance_and_sync() and compute_threshold() - Drive time forward when all CPUs are idle via idle_tick_method() SC_METHOD - Protect shared state across vCPU and SystemC threads with m_mcips_mutex - Drain in-flight callbacks safely on shutdown via shutdown_cleanup() and m_inflight_cb refcount Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
- add mcips_plugin as a std::unique_ptr for conditional construction.
- add CCI params: "p_enable_mcips_plugin" (enable/disable mcips_plugin).
- push plugin args (idlinker) in QemuInstance constructor only when enabled.
- add helper functions:
* get_mcips_plugin() asserts plugin is constructed before returning reference.
* is_mcips_enabled() checks both CCI parameter and actual construction state.
Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
- Skip QK and related scheduling/timer/wait logic if multi core instructions per second (mcips) is enabled - if mcips is enabled pass the ips value for this cpu to the plugin by calling mcips_plugin.set_vcpu_insn_per_second(cpu_index, insn_per_second) Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
- export plugin status such as qemu_time, cpu_time, cpu_speed(ips), cpu_index, cpu_status(IDLE, PAUSED, RUNNING) and more to monitor - add cci value p_refresh_interval_ms (refresh interval in milliseconds for the web interface) Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
Only generate mcips=true when threading=MULTI and accel=tcg. For COROUTINE or SINGLE (or non-tcg), only mcips=false is generated. add option -DQBOX_ENABLE_MCIPS_TESTS to enable/disable MCIPS tests (default=ON) Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
…cycle (SC_ZERO_TIME) Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
Replace m_cpus[cpuid].halt_cb(true) with a per-cpu gs::async_event array so each CPU independently detaches the suspending event when it completes, preventing early simulation termination in multi-cpu runs. Also add async_event suspend/detach to the hexagon ld-st-mmio test. Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
covering configuration, behavior, and synchronization model Signed-off-by: Alwalid Salama <asalama@qti.qualcomm.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.