From c06565aa4ec2c6c9d89564ef72421e300b05bf97 Mon Sep 17 00:00:00 2001 From: friemel Date: Tue, 17 Jul 2012 15:35:29 +0000 Subject: [PATCH] Basic SAL files and makefile modifications for adding gem5. git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1457 8c4709b5-6ec9-48aa-a5cd-a96041d1645a --- CMakeLists.txt | 9 +++++++-- cmake/gem5.cmake | 7 +++++++ simulators/gem5/build_debug.sh | 1 + src/core/config/VariantConfig.hpp.in | 1 + src/core/cpn/JobServer.cc | 2 +- src/core/sal/CMakeLists.txt | 12 +++++++++++- src/core/sal/SALConfig.hpp | 2 ++ src/core/sal/SALInst.hpp | 11 +++++++++++ src/core/sal/gem5/Gem5Config.hpp | 22 ++++++++++++++++++++++ src/core/sal/gem5/Gem5Controller.cc | 7 +++++++ src/core/sal/gem5/Gem5Controller.hpp | 19 +++++++++++++++++++ src/core/sal/gem5/SConscript | 9 +++++++++ src/core/sal/gem5/faildev.cc | 1 + src/core/sal/gem5/faildev.hh | 1 + 14 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 cmake/gem5.cmake create mode 100644 simulators/gem5/build_debug.sh create mode 100644 src/core/sal/gem5/Gem5Config.hpp create mode 100644 src/core/sal/gem5/Gem5Controller.cc create mode 100644 src/core/sal/gem5/Gem5Controller.hpp create mode 100644 src/core/sal/gem5/SConscript create mode 100644 src/core/sal/gem5/faildev.cc create mode 100644 src/core/sal/gem5/faildev.hh diff --git a/CMakeLists.txt b/CMakeLists.txt index 8658dfbe..d6aad65a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,13 +27,17 @@ SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) include(compilerconfig) #### #OPTION to configure Bochs/OVP #### -OPTION(BUILD_OVP "Build OVP Variant?" OFF) # Defaults to BOCHS ON -OPTION(BUILD_BOCHS "Build Bochs Variant?" ON) +OPTION( BUILD_OVP "Build OVP Variant?" OFF) # Defaults to BOCHS ON +OPTION( BUILD_GEM5 "Build gem5 Variant?" OFF) +OPTION( BUILD_BOCHS "Build Bochs Variant?" ON) if(BUILD_BOCHS) ## add necessary additional header search paths. #add_definitions(-I${CMAKE_SOURCE_DIR}/simulators/bochs/instrument/stubs/ -I${CMAKE_SOURCE_DIR}/simulators/bochs) include_directories(simulators/bochs/instrument/stubs simulators/bochs) +elseif(BUILD_GEM5) + include_directories(simulators/gem5/src simulators/gem5/build/ARM) + add_definitions(-std=c++0x) elseif(BUILD_OVP) add_subdirectory(simulators/ovp) endif(BUILD_BOCHS) @@ -55,6 +59,7 @@ add_subdirectory(src) #### Backend-related build system stuff include(bochs) include(ovp) +include(gem5) ## Just for testing: ## Invoking bochs build via external project diff --git a/cmake/gem5.cmake b/cmake/gem5.cmake new file mode 100644 index 00000000..7dce4bec --- /dev/null +++ b/cmake/gem5.cmake @@ -0,0 +1,7 @@ +#### gem5-specific stuff +if(BUILD_GEM5) + message(STATUS "[${PROJECT_NAME}] Building gem5 variant ...") + SET(VARIANT gem5) + + #set(gem5_src_dir ${PROJECT_SOURCE_DIR}/simulators/gem5) +endif(BUILD_GEM5) diff --git a/simulators/gem5/build_debug.sh b/simulators/gem5/build_debug.sh new file mode 100644 index 00000000..18c1f028 --- /dev/null +++ b/simulators/gem5/build_debug.sh @@ -0,0 +1 @@ +scons EXTRAS=../../src/core/sal/gem5 --colors build/ARM/gem5.debug -j4 diff --git a/src/core/config/VariantConfig.hpp.in b/src/core/config/VariantConfig.hpp.in index 6e591b3f..b2b2fd7e 100644 --- a/src/core/config/VariantConfig.hpp.in +++ b/src/core/config/VariantConfig.hpp.in @@ -3,5 +3,6 @@ #cmakedefine BUILD_OVP #cmakedefine BUILD_BOCHS +#cmakedefine BUILD_GEM5 #endif // __VARIANT_CONFIG_HPP__ diff --git a/src/core/cpn/JobServer.cc b/src/core/cpn/JobServer.cc index dc4463e9..b51842a5 100644 --- a/src/core/cpn/JobServer.cc +++ b/src/core/cpn/JobServer.cc @@ -137,7 +137,7 @@ void JobServer::run() saddr.sin_addr.s_addr = htons(INADDR_ANY); /* bind to port */ - if (bind(s, (struct sockaddr*) &saddr, sizeof(saddr)) == -1) { + if (::bind(s, (struct sockaddr*) &saddr, sizeof(saddr)) == -1) { perror("bind"); // TODO: Log-level? return; diff --git a/src/core/sal/CMakeLists.txt b/src/core/sal/CMakeLists.txt index 185a07c5..caccca89 100644 --- a/src/core/sal/CMakeLists.txt +++ b/src/core/sal/CMakeLists.txt @@ -9,7 +9,7 @@ if(BUILD_BOCHS) bochs/BochsController.cc bochs/BochsListener.cc ) -else() +elseif(BUILD_OVP) set(SRCS BufferCache.cc Listener.cc @@ -19,6 +19,16 @@ else() SimulatorController.cc ${VARIANT}/OVPController.cc ) +elseif(BUILD_GEM5) + set(SRCS + BufferCache.cc + Listener.cc + ListenerManager.cc + Memory.cc + Register.cc + SimulatorController.cc + gem5/Gem5Controller.cc + ) endif(BUILD_BOCHS) add_library(sal ${SRCS}) diff --git a/src/core/sal/SALConfig.hpp b/src/core/sal/SALConfig.hpp index 5aae2f59..e3f17a29 100644 --- a/src/core/sal/SALConfig.hpp +++ b/src/core/sal/SALConfig.hpp @@ -10,6 +10,8 @@ #include "bochs/BochsConfig.hpp" #elif defined BUILD_OVP #include "ovp/OVPConfig.hpp" +#elif defined BUILD_GEM5 + #include "gem5/Gem5Config.hpp" #else #error SAL Config Target not defined #endif diff --git a/src/core/sal/SALInst.hpp b/src/core/sal/SALInst.hpp index ca814cfe..228fc2ca 100644 --- a/src/core/sal/SALInst.hpp +++ b/src/core/sal/SALInst.hpp @@ -26,6 +26,17 @@ extern ConcreteSimulatorController simulator; //!< the global simulator-controll } +#elif defined BUILD_GEM5 + +#include "gem5/Gem5Controller.hpp" + +namespace fail { + +typedef Gem5Controller ConcreteSimulatorController; //!< concrete simulator (type) +extern ConcreteSimulatorController simulator; //!< the global simulator-controller instance + +} + #else #error SAL Instance not defined #endif diff --git a/src/core/sal/gem5/Gem5Config.hpp b/src/core/sal/gem5/Gem5Config.hpp new file mode 100644 index 00000000..81abb055 --- /dev/null +++ b/src/core/sal/gem5/Gem5Config.hpp @@ -0,0 +1,22 @@ +/** + * \brief Type definitions and configuration settings for + * the gem5 simulator. + */ + +#ifndef __GEM5_CONFIG_HPP__ + #define __GEM5_CONFIG_HPP__ + +#include "base/types.hh" +#include "arch/arm/registers.hh" + +namespace fail { + +typedef Addr guest_address_t; //!< the guest memory address type +// TODO: Set Host Address Type +typedef void* host_address_t; //!< the host memory address type +typedef ArmISA::AnyReg register_data_t; //!< register data type (32 bit) +typedef int timer_t; //!< type of timer IDs + +} // end-of-namespace: fail + +#endif // __GEM5_CONFIG_HPP__ diff --git a/src/core/sal/gem5/Gem5Controller.cc b/src/core/sal/gem5/Gem5Controller.cc new file mode 100644 index 00000000..ddf013eb --- /dev/null +++ b/src/core/sal/gem5/Gem5Controller.cc @@ -0,0 +1,7 @@ + + +namespace fail { + +int interrupt_to_fire = -1; + +} // end-of-namespace: fail \ No newline at end of file diff --git a/src/core/sal/gem5/Gem5Controller.hpp b/src/core/sal/gem5/Gem5Controller.hpp new file mode 100644 index 00000000..c1f29500 --- /dev/null +++ b/src/core/sal/gem5/Gem5Controller.hpp @@ -0,0 +1,19 @@ +#ifndef __GEM5_CONTROLLER_HPP__ + #define __GEM5_CONTROLLER_HPP__ + +#include "../SimulatorController.hpp" + +namespace fail { + +extern int interrupt_to_fire; + +class Gem5Controller : public SimulatorController { +public: + virtual void save(const std::string &path); + virtual void restore(const std::string &path); + virtual void reboot(); +}; + +} // end-of-namespace: fail + +#endif // __GEM_CONTROLLER_HPP__ diff --git a/src/core/sal/gem5/SConscript b/src/core/sal/gem5/SConscript new file mode 100644 index 00000000..6450d62b --- /dev/null +++ b/src/core/sal/gem5/SConscript @@ -0,0 +1,9 @@ +Import('*') + +if env['TARGET_ISA'] == 'no': + Return() + +env.Append(CPPPATH=Dir('../../../../../src/core/')) +env.Append(CPPPATH=Dir('../../../../../build/src/core/')) + +Source('faildev.cc') diff --git a/src/core/sal/gem5/faildev.cc b/src/core/sal/gem5/faildev.cc new file mode 100644 index 00000000..b1a05cb2 --- /dev/null +++ b/src/core/sal/gem5/faildev.cc @@ -0,0 +1 @@ +#include "faildev.hh" \ No newline at end of file diff --git a/src/core/sal/gem5/faildev.hh b/src/core/sal/gem5/faildev.hh new file mode 100644 index 00000000..4a60a677 --- /dev/null +++ b/src/core/sal/gem5/faildev.hh @@ -0,0 +1 @@ +#include "../SALInst.hpp" \ No newline at end of file