summaryrefslogtreecommitdiff
path: root/src/core/loader.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2014-05-26 20:52:00 -0400
committerGravatar bunnei2014-05-26 20:52:00 -0400
commit6448c2f30062c085330ff26a4812c9a91c7b492c (patch)
tree386e32cf3ec053491fb8dfd8459a1c92553241d9 /src/core/loader.cpp
parentMerge pull request #4 from archshift/patch-1 (diff)
parentservice: fixed typo that MSVC did not catch as an error (diff)
downloadyuzu-6448c2f30062c085330ff26a4812c9a91c7b492c.tar.gz
yuzu-6448c2f30062c085330ff26a4812c9a91c7b492c.tar.xz
yuzu-6448c2f30062c085330ff26a4812c9a91c7b492c.zip
Merge pull request #9 from bunnei/master
Add initial kernel HLE, includes thread creation and context switching
Diffstat (limited to '')
-rw-r--r--src/core/loader.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/core/loader.cpp b/src/core/loader.cpp
index 8756588ae..ff1c873bb 100644
--- a/src/core/loader.cpp
+++ b/src/core/loader.cpp
@@ -10,7 +10,7 @@
10#include "core/core.h" 10#include "core/core.h"
11#include "core/file_sys/directory_file_system.h" 11#include "core/file_sys/directory_file_system.h"
12#include "core/elf/elf_reader.h" 12#include "core/elf/elf_reader.h"
13 13#include "core/hle/kernel/kernel.h"
14#include "core/mem_map.h" 14#include "core/mem_map.h"
15 15
16//////////////////////////////////////////////////////////////////////////////////////////////////// 16////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -56,7 +56,7 @@ bool Load_ELF(std::string &filename) {
56 elf_reader = new ElfReader(buffer); 56 elf_reader = new ElfReader(buffer);
57 elf_reader->LoadInto(0x00100000); 57 elf_reader->LoadInto(0x00100000);
58 58
59 Core::g_app_core->SetPC(elf_reader->GetEntryPoint()); 59 Kernel::LoadExec(elf_reader->GetEntryPoint());
60 60
61 delete[] buffer; 61 delete[] buffer;
62 delete elf_reader; 62 delete elf_reader;
@@ -89,11 +89,11 @@ bool Load_DAT(std::string &filename) {
89 * but for the sake of making it easier... we'll temporarily/hackishly 89 * but for the sake of making it easier... we'll temporarily/hackishly
90 * allow it. No sense in making a proper reader for this. 90 * allow it. No sense in making a proper reader for this.
91 */ 91 */
92 u32 entrypoint = 0x00100000; // write to same entrypoint as elf 92 u32 entry_point = 0x00100000; // write to same entrypoint as elf
93 u32 payload_offset = 0xA150; 93 u32 payload_offset = 0xA150;
94 94
95 const u8 *src = &buffer[payload_offset]; 95 const u8 *src = &buffer[payload_offset];
96 u8 *dst = Memory::GetPointer(entrypoint); 96 u8 *dst = Memory::GetPointer(entry_point);
97 u32 srcSize = size - payload_offset; //just load everything... 97 u32 srcSize = size - payload_offset; //just load everything...
98 u32 *s = (u32*)src; 98 u32 *s = (u32*)src;
99 u32 *d = (u32*)dst; 99 u32 *d = (u32*)dst;
@@ -102,7 +102,8 @@ bool Load_DAT(std::string &filename) {
102 *d++ = (*s++); 102 *d++ = (*s++);
103 } 103 }
104 104
105 Core::g_app_core->SetPC(entrypoint); 105 Kernel::LoadExec(entry_point);
106
106 107
107 delete[] buffer; 108 delete[] buffer;
108 } 109 }
@@ -131,10 +132,10 @@ bool Load_BIN(std::string &filename) {
131 132
132 f.ReadBytes(buffer, size); 133 f.ReadBytes(buffer, size);
133 134
134 u32 entrypoint = 0x00100000; // Hardcoded, read from exheader 135 u32 entry_point = 0x00100000; // Hardcoded, read from exheader
135 136
136 const u8 *src = buffer; 137 const u8 *src = buffer;
137 u8 *dst = Memory::GetPointer(entrypoint); 138 u8 *dst = Memory::GetPointer(entry_point);
138 u32 srcSize = size; 139 u32 srcSize = size;
139 u32 *s = (u32*)src; 140 u32 *s = (u32*)src;
140 u32 *d = (u32*)dst; 141 u32 *d = (u32*)dst;
@@ -143,7 +144,7 @@ bool Load_BIN(std::string &filename) {
143 *d++ = (*s++); 144 *d++ = (*s++);
144 } 145 }
145 146
146 Core::g_app_core->SetPC(entrypoint); 147 Kernel::LoadExec(entry_point);
147 148
148 delete[] buffer; 149 delete[] buffer;
149 } 150 }
@@ -186,6 +187,9 @@ FileType IdentifyFile(std::string &filename) {
186 else if (!strcasecmp(extension.c_str(), ".elf")) { 187 else if (!strcasecmp(extension.c_str(), ".elf")) {
187 return FILETYPE_CTR_ELF; // TODO(bunnei): Do some filetype checking :p 188 return FILETYPE_CTR_ELF; // TODO(bunnei): Do some filetype checking :p
188 } 189 }
190 else if (!strcasecmp(extension.c_str(), ".axf")) {
191 return FILETYPE_CTR_ELF; // TODO(bunnei): Do some filetype checking :p
192 }
189 else if (!strcasecmp(extension.c_str(), ".bin")) { 193 else if (!strcasecmp(extension.c_str(), ".bin")) {
190 return FILETYPE_CTR_BIN; 194 return FILETYPE_CTR_BIN;
191 } 195 }