diff options
Diffstat (limited to 'src/sim/process.hh')
-rw-r--r-- | src/sim/process.hh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/sim/process.hh b/src/sim/process.hh index 8e353071c..a28d58e9a 100644 --- a/src/sim/process.hh +++ b/src/sim/process.hh @@ -183,6 +183,38 @@ class Process : public SimObject SETranslatingPortProxy initVirtMem; // memory proxy for initial image load + /** + * Each instance of a Loader subclass will have a chance to try to load + * an object file when tryLoaders is called. If they can't because they + * aren't compatible with it (wrong arch, wrong OS, etc), then they + * silently fail by returning nullptr so other loaders can try. + */ + class Loader + { + public: + Loader(); + + /* Loader instances are singletons. */ + Loader(const Loader &) = delete; + void operator=(const Loader &) = delete; + + virtual ~Loader() {} + + /** + * Each subclass needs to implement this method. If the loader is + * compatible with the passed in object file, it should return the + * created Process object corresponding to it. If not, it should fail + * silently and return nullptr. If there's a non-compatibliity related + * error like file IO errors, etc., those should fail non-silently + * with a panic or fail as normal. + */ + virtual Process *load(ProcessParams *params, ObjectFile *obj_file) = 0; + }; + + // Try all the Loader instance's "load" methods one by one until one is + // successful. If none are, complain and fail. + static Process *tryLoaders(ProcessParams *params, ObjectFile *obj_file); + ObjectFile *objFile; MemoryImage image; MemoryImage interpImage; |