diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-07-10 14:25:37 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-07-10 14:25:37 +0200 |
| commit | 0402a1c2feb8e8036c56dfc51d13e63ef3133208 (patch) | |
| tree | 3d916e3e38fbb1b63eb29c97da1f5b6441f0dad1 /Boot/Sources/ProgramLoader.cxx | |
| parent | 7516413c8b3156cc75e349f5f8b3392c3b4f885d (diff) | |
[MHR-36] Giving priority to NVMe module suport.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Boot/Sources/ProgramLoader.cxx')
| -rw-r--r-- | Boot/Sources/ProgramLoader.cxx | 88 |
1 files changed, 50 insertions, 38 deletions
diff --git a/Boot/Sources/ProgramLoader.cxx b/Boot/Sources/ProgramLoader.cxx index 90175bef..0603fb9c 100644 --- a/Boot/Sources/ProgramLoader.cxx +++ b/Boot/Sources/ProgramLoader.cxx @@ -7,60 +7,72 @@ #include <BootKit/ProgramLoader.hxx> #include <BootKit/Vendor/Support.hxx> #include <BootKit/BootKit.hxx> + +EXTERN_C +{ #include <string.h> +} namespace Boot { ProgramLoader::ProgramLoader(VoidPtr blob) : fBlob(blob), fStartAddress(nullptr) { - // detect the format. - const char* firstBytes = reinterpret_cast<char*>(fBlob); + // detect the format. + const Char* firstBytes = reinterpret_cast<char*>(fBlob); - BTextWriter writer; - writer.WriteCharacter(firstBytes[0]).WriteCharacter(firstBytes[1]).WriteCharacter('\r').WriteCharacter('\n'); + BTextWriter writer; - if (!firstBytes) - { - // failed to provide a valid pointer. - return; - } + if (!firstBytes) + { + // failed to provide a valid pointer. + return; + } - if (firstBytes[0] == 'M' && - firstBytes[1] == 'Z') - { - // Parse PE32+ - fStartAddress = nullptr; - } - else if (firstBytes[0] == 'J' && - firstBytes[1] == 'o' && - firstBytes[2] == 'y' && - firstBytes[3] == '!') - { - // Parse Non FAT PEF. - fStartAddress = nullptr; - } - else - { - // probably a binary blob. - fStartAddress = fBlob; - } - } + if (firstBytes[0] == 'M' && + firstBytes[1] == 'Z') + { + // Parse PE32+ + fStartAddress = nullptr; + writer.Write("newosldr: MZ executable detected.\r"); + } + else if (firstBytes[0] == 'J' && + firstBytes[1] == 'o' && + firstBytes[2] == 'y' && + firstBytes[3] == '!') + { + // Parse Non FAT PEF. + fStartAddress = nullptr; + writer.Write("newosldr: PEF executable detected.\r"); + } + else + { + // probably a binary blob. + fStartAddress = fBlob; + } + } Void ProgramLoader::Start(HEL::HandoverInformationHeader* handover) { - if (!fStartAddress) return; + BTextWriter writer; + writer.Write("newosldr: running: ").Write(fBlobName).Write("\r"); + + if (!fStartAddress) + { + writer.Write("newosldr: exec error.\r"); + return; + } - ((HEL::HandoverProc)fStartAddress)(handover); + ((HEL::HandoverProc)fStartAddress)(handover); } const Char* ProgramLoader::GetName() - { - return fBlobName; - } + { + return fBlobName; + } Void ProgramLoader::SetName(const Char* name) - { - CopyMem(fBlobName, name, StrLen(name)); - } -} // namespace Boot
\ No newline at end of file + { + CopyMem(fBlobName, name, StrLen(name)); + } +} // namespace Boot |
