KernelState should handle module launching

This commit is contained in:
Dr. Chat
2016-10-24 11:00:22 -05:00
parent 69be82c786
commit a148b965f1
12 changed files with 85 additions and 64 deletions

View File

@@ -53,6 +53,11 @@ struct elf32_phdr {
xe::be<uint32_t> p_align;
};
bool ElfModule::is_executable() const {
auto hdr = reinterpret_cast<const elf32_ehdr*>(elf_header_mem_.data());
return hdr->e_entry != 0;
}
bool ElfModule::Load(const std::string& name, const std::string& path,
const void* elf_addr, size_t elf_length) {
name_ = name;

View File

@@ -31,6 +31,7 @@ class ElfModule : public xe::cpu::Module {
bool loaded() const { return loaded_; }
uint32_t entry_point() const { return entry_point_; }
const std::string& name() const override { return name_; }
bool is_executable() const override;
const std::string& path() const { return path_; }
bool Load(const std::string& name, const std::string& path,

View File

@@ -34,6 +34,7 @@ class Module {
Memory* memory() const { return memory_; }
virtual const std::string& name() const = 0;
virtual bool is_executable() const = 0;
virtual bool ContainsAddress(uint32_t address);

View File

@@ -60,6 +60,7 @@ class BuiltinModule : public Module {
: Module(processor), name_("builtin") {}
const std::string& name() const override { return name_; }
bool is_executable() const override { return false; }
bool ContainsAddress(uint32_t address) override {
return (address & 0xFFFFFFF0) == 0xFFFFFFF0;

View File

@@ -29,7 +29,9 @@ class RawModule : public Module {
void SetAddressRange(uint32_t base_address, uint32_t size);
const std::string& name() const override { return name_; }
bool is_executable() const override { return is_executable_; }
void set_name(const std::string& name) { name_ = name; }
void set_executable(bool is_executable) { is_executable_ = is_executable; }
bool ContainsAddress(uint32_t address) override;
@@ -38,6 +40,7 @@ class RawModule : public Module {
private:
std::string name_;
bool is_executable_ = false;
uint32_t base_address_;
uint32_t low_address_;
uint32_t high_address_;

View File

@@ -30,6 +30,7 @@ class TestModule : public Module {
~TestModule() override;
const std::string& name() const override { return name_; }
bool is_executable() const override { return false; }
bool ContainsAddress(uint32_t address) override;

View File

@@ -75,6 +75,9 @@ class XexModule : public xe::cpu::Module {
bool Unload();
const std::string& name() const override { return name_; }
bool is_executable() const override {
return (xex_header()->module_flags & XEX_MODULE_TITLE) != 0;
}
bool ContainsAddress(uint32_t address) override;