diff options
author | Alexis211 <alexis211@gmail.com> | 2009-10-18 10:34:11 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-10-18 10:34:11 +0200 |
commit | 22c06556ccbd07f4ef7da39a62d10e03fbee3fe0 (patch) | |
tree | 8b45002ef347b625c9134091a7dfad9ed16c5274 /Source/Kernel/Linker/MelonBinary.class.cpp | |
parent | 7dc8c19f7d6220c9e3dac43796faf77c4f11974f (diff) | |
download | Melon-22c06556ccbd07f4ef7da39a62d10e03fbee3fe0.tar.gz Melon-22c06556ccbd07f4ef7da39a62d10e03fbee3fe0.zip |
Loading binaries now is done through a much more unified interface.
Diffstat (limited to 'Source/Kernel/Linker/MelonBinary.class.cpp')
-rw-r--r-- | Source/Kernel/Linker/MelonBinary.class.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Source/Kernel/Linker/MelonBinary.class.cpp b/Source/Kernel/Linker/MelonBinary.class.cpp new file mode 100644 index 0000000..d6074de --- /dev/null +++ b/Source/Kernel/Linker/MelonBinary.class.cpp @@ -0,0 +1,30 @@ +#include "MelonBinary.class.h" + +Binary* MelonBinary::load(File& file) { + u32int magic; + file.read<u32int>(&magic); + if (magic == 0xFEEDBEEF) { + MelonBinary* r = new MelonBinary; + file.read<u32int>(&r->m_size); + file.read<u32int>(&r->m_org); + r->m_data = (u8int*)Mem::kalloc(r->m_size); + file.read(r->m_size, r->m_data); + return r; + } else { + return 0; + } +} + +MelonBinary::~MelonBinary() { + delete m_data; +} + +thread_entry_t MelonBinary::toProcess(Process* p) { + if (p == 0) return 0; + for (u32int i = m_org; i < m_org + m_size; i += 0x1000) { + p->getPagedir()->allocFrame(i, true, true); + } + p->getPagedir()->switchTo(); + memcpy((u8int*)m_org, m_data, m_size); + return (thread_entry_t)m_org; +} |