summaryrefslogtreecommitdiffhomepage
path: root/Boot/Sources
diff options
context:
space:
mode:
authorAmlal <amlalelmahrouss@icloud.com>2024-07-28 16:11:46 +0000
committerAmlal <amlalelmahrouss@icloud.com>2024-07-28 16:11:46 +0000
commitc4023005e029ae092dad2689564c490580dd5c28 (patch)
tree3080ba07a6b552bf3d7591574cf69b2a3c8fd0fd /Boot/Sources
parent8c8822fff78f9ff9cd640271da9b3634c4c2f97f (diff)
parent4db57a2d646b1538783a0675b38bada7a0f903ae (diff)
Merged in MHR-36 (pull request #17)
MHR-36
Diffstat (limited to 'Boot/Sources')
-rw-r--r--Boot/Sources/BootloaderRsrc.rsrc8
-rw-r--r--Boot/Sources/HEL/64X000/Boot64x0.S2
-rw-r--r--Boot/Sources/HEL/AMD64/BootAHCI.cxx4
-rw-r--r--Boot/Sources/HEL/AMD64/BootATA.cxx4
-rw-r--r--Boot/Sources/HEL/AMD64/BootFileReader.cxx85
-rw-r--r--Boot/Sources/HEL/AMD64/BootJump.S11
-rw-r--r--Boot/Sources/HEL/AMD64/BootMain.cxx165
-rw-r--r--Boot/Sources/HEL/AMD64/BootPlatform.cxx5
-rw-r--r--Boot/Sources/HEL/AMD64/BootString.cxx2
-rw-r--r--Boot/Sources/HEL/AMD64/BootTextWriter.cxx36
-rw-r--r--Boot/Sources/HEL/AMD64/New+Delete.cxx4
-rw-r--r--Boot/Sources/HEL/AMD64/Support.cxx10
-rw-r--r--Boot/Sources/HEL/AMD64/compile_flags.txt6
-rw-r--r--Boot/Sources/HEL/POWER/CoreBootStartup.S2
-rw-r--r--Boot/Sources/ProgramLoader.cxx115
-rw-r--r--Boot/Sources/Root/SplashScreen.fmt7
-rw-r--r--Boot/Sources/Root/ZETA/BootLoader-Load.webmbin0 -> 22081 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-Black.ttfbin0 -> 42784 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-BlackItalic.ttfbin0 -> 44084 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-Bold.ttfbin0 -> 42636 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-BoldItalic.ttfbin0 -> 43900 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-ExtraBold.ttfbin0 -> 42908 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-ExtraBoldItalic.ttfbin0 -> 44208 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-ExtraLight.ttfbin0 -> 42792 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-ExtraLightItalic.ttfbin0 -> 44104 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-Italic.ttfbin0 -> 43996 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-Light.ttfbin0 -> 42764 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-LightItalic.ttfbin0 -> 44052 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-Medium.ttfbin0 -> 42752 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-MediumItalic.ttfbin0 -> 44080 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-Regular.ttfbin0 -> 42704 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-SemiBold.ttfbin0 -> 42740 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-SemiBoldItalic.ttfbin0 -> 44088 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-Thin.ttfbin0 -> 42580 bytes
-rw-r--r--Boot/Sources/Root/ZETA/Urbanist-ThinItalic.ttfbin0 -> 43868 bytes
-rw-r--r--Boot/Sources/Root/ZETA/fonts.json4
-rw-r--r--Boot/Sources/Root/bootloader.json4
-rw-r--r--Boot/Sources/compile_flags.txt4
38 files changed, 325 insertions, 153 deletions
diff --git a/Boot/Sources/BootloaderRsrc.rsrc b/Boot/Sources/BootloaderRsrc.rsrc
index 92ff177f..7064db76 100644
--- a/Boot/Sources/BootloaderRsrc.rsrc
+++ b/Boot/Sources/BootloaderRsrc.rsrc
@@ -1,6 +1,6 @@
#include "../../Kernel/CompilerKit/Version.hxx"
-1 ICON "../../Icons/boot-logo.ico"
+1 ICON "../../Icons/main.ico"
1 VERSIONINFO
FILEVERSION 1,0,0,0
@@ -10,11 +10,11 @@ BEGIN
BEGIN
BLOCK "080904E4"
BEGIN
- VALUE "CompanyName", "Zeta Electronics Corporation"
- VALUE "FileDescription", "New OS multi-platform bootloader."
+ VALUE "CompanyName", "ZKA Technologies"
+ VALUE "FileDescription", "New OS Loader."
VALUE "FileVersion", BOOTLOADER_VERSION
VALUE "InternalName", "newosldr"
- VALUE "LegalCopyright", "Copyright Zeta Electronics Corporation, all rights reserved."
+ VALUE "LegalCopyright", "Copyright ZKA Technologies, all rights reserved."
VALUE "OriginalFilename", "newosldr.exe"
VALUE "ProductName", "newosldr"
VALUE "ProductVersion", BOOTLOADER_VERSION
diff --git a/Boot/Sources/HEL/64X000/Boot64x0.S b/Boot/Sources/HEL/64X000/Boot64x0.S
index 9b2fb569..37b82b6f 100644
--- a/Boot/Sources/HEL/64X000/Boot64x0.S
+++ b/Boot/Sources/HEL/64X000/Boot64x0.S
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
------------------------------------------- */
diff --git a/Boot/Sources/HEL/AMD64/BootAHCI.cxx b/Boot/Sources/HEL/AMD64/BootAHCI.cxx
index 7d07f8f0..ef327652 100644
--- a/Boot/Sources/HEL/AMD64/BootAHCI.cxx
+++ b/Boot/Sources/HEL/AMD64/BootAHCI.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
------------------------------------------- */
@@ -11,7 +11,7 @@
* @version 0.1
* @date 2024-02-02
*
- * @copyright Copyright (c) Zeta Electronics Corporation
+ * @copyright Copyright (c) ZKA Technologies
*
*/
diff --git a/Boot/Sources/HEL/AMD64/BootATA.cxx b/Boot/Sources/HEL/AMD64/BootATA.cxx
index 55a55a0c..1a59ce5c 100644
--- a/Boot/Sources/HEL/AMD64/BootATA.cxx
+++ b/Boot/Sources/HEL/AMD64/BootATA.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
------------------------------------------- */
@@ -11,7 +11,7 @@
* @version 0.1
* @date 2024-02-02
*
- * @copyright Copyright (c) Zeta Electronics Corporation
+ * @copyright Copyright (c) ZKA Technologies
*
*/
diff --git a/Boot/Sources/HEL/AMD64/BootFileReader.cxx b/Boot/Sources/HEL/AMD64/BootFileReader.cxx
index b5498cf9..f784bf6f 100644
--- a/Boot/Sources/HEL/AMD64/BootFileReader.cxx
+++ b/Boot/Sources/HEL/AMD64/BootFileReader.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
File: FileReader.cxx
Purpose: New Boot FileReader,
@@ -13,7 +13,6 @@
#include <BootKit/BootKit.hxx>
#include <FirmwareKit/Handover.hxx>
#include <FirmwareKit/EFI/API.hxx>
-#include <cstddef>
/// @file BootFileReader
/// @brief Bootloader File reader.
@@ -49,28 +48,27 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path,
EfiGUID guidEfp = EfiGUID(EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID);
- EfiSimpleFilesystemProtocol* efp = nullptr;
- EfiFileProtocol* rootFs = nullptr;
+ EfiSimpleFilesystemProtocol* efp = nullptr;
EfiLoadImageProtocol* img = nullptr;
EfiGUID guidImg = EfiGUID(EFI_LOADED_IMAGE_PROTOCOL_GUID);
if (BS->HandleProtocol(ImageHandle, &guidImg, (void**)&img) != kEfiOk)
{
- mWriter.Write(L"newosldr: Fetch-Protocol: No-Such-Protocol").Write(L"\r");
+ mWriter.Write(L"newosldr: Handle-Protocol: No-Such-Protocol").Write(L"\r");
this->mErrorCode = kNotSupported;
}
if (BS->HandleProtocol(img->DeviceHandle, &guidEfp, (void**)&efp) != kEfiOk)
{
- mWriter.Write(L"newosldr: Fetch-Protocol: No-Such-Protocol").Write(L"\r");
+ mWriter.Write(L"newosldr: Handle-Protocol: No-Such-Protocol").Write(L"\r");
this->mErrorCode = kNotSupported;
return;
}
/// Start doing disk I/O
- if (efp->OpenVolume(efp, &rootFs) != kEfiOk)
+ if (efp->OpenVolume(efp, &mRootFs) != kEfiOk)
{
mWriter.Write(L"newosldr: Fetch-Protocol: No-Such-Volume").Write(L"\r");
this->mErrorCode = kNotSupported;
@@ -79,18 +77,19 @@ BFileReader::BFileReader(const CharacterTypeUTF16* path,
EfiFileProtocol* kernelFile = nullptr;
- if (rootFs->Open(rootFs, &kernelFile, mPath, kEFIFileRead, kEFIReadOnly) !=
+ if (mRootFs->Open(mRootFs, &kernelFile, mPath, kEFIFileRead, kEFIReadOnly) !=
kEfiOk)
{
mWriter.Write(L"newosldr: Fetch-Protocol: No-Such-Path: ")
.Write(mPath)
.Write(L"\r");
this->mErrorCode = kNotSupported;
+
+ mRootFs->Close(mRootFs);
+
return;
}
- rootFs->Close(rootFs);
-
mSizeFile = 0;
mFile = kernelFile;
mErrorCode = kOperationOkay;
@@ -104,50 +103,80 @@ BFileReader::~BFileReader()
this->mFile = nullptr;
}
+ if (this->mRootFs)
+ {
+ this->mRootFs->Close(this->mRootFs);
+ this->mRootFs = nullptr;
+ }
+
if (this->mBlob)
- BS->FreePool(mBlob);
+ {
+ BS->FreePool(this->mBlob);
+ this->mBlob = nullptr;
+ }
BSetMem(this->mPath, 0, kPathLen);
}
/**
- @brief this reads all of the buffer.
- @param until read until size is reached.
+ @brief Reads all of the file into a buffer.
+ @param **readUntil** size of file
+ @param **chunkToRead** chunk to read each time.
*/
-Void BFileReader::ReadAll(SizeT until, SizeT chunk)
+Void BFileReader::ReadAll(SizeT readUntil, SizeT chunkToRead)
{
if (mBlob == nullptr)
{
- if (auto err = BS->AllocatePool(EfiLoaderCode, until, (VoidPtr*)&mBlob) !=
+ EfiFileInfo newPtrInfo;
+ UInt32 szInfo = 0;
+
+ EfiGUID cFileInfoGUID = EFI_FILE_INFO_GUID;
+
+ if (mFile->GetInfo(mFile, &cFileInfoGUID, &szInfo, &newPtrInfo) == kEfiOk)
+ {
+ if (newPtrInfo.FileSize < readUntil)
+ readUntil = newPtrInfo.FileSize;
+ else if (readUntil < 1)
+ readUntil = newPtrInfo.FileSize;
+
+ mWriter.Write(L"newosldr: physical size: ").Write(readUntil).Write("\r");
+ }
+
+ if (auto err = BS->AllocatePool(EfiLoaderCode, readUntil, (VoidPtr*)&mBlob) !=
kEfiOk)
{
- mWriter.Write(L"*** EFI-Code: ").Write(err).Write(L" ***\r");
+ mWriter.Write(L"*** error: ").Write(err).Write(L" ***\r");
EFI::ThrowError(L"OutOfMemory", L"Out of memory.");
}
}
mErrorCode = kNotSupported;
- UInt64 bufSize = chunk;
- UInt64 szCnt = 0;
- UInt64 curSz = 0;
+ UInt64 bufSize = chunkToRead;
+ UInt64 szCnt = 0UL;
- while (szCnt < until)
+ while (szCnt < readUntil)
{
- if (mFile->Read(mFile, &bufSize, (VoidPtr)((UIntPtr)mBlob + curSz)) !=
- kEfiOk)
- {
- break;
- }
+ auto res = mFile->Read(mFile, &bufSize, (VoidPtr)(&((Char*)mBlob)[szCnt]));
szCnt += bufSize;
- curSz += bufSize;
- if (bufSize == 0)
+ if (res == kBufferTooSmall)
+ {
+ mErrorCode = kTooSmall;
+ return;
+ }
+ else if (res == kEfiOk)
+ {
+ continue;
+ }
+ else
+ {
break;
+ }
}
- mSizeFile = curSz;
+ mSizeFile = szCnt;
mErrorCode = kOperationOkay;
}
diff --git a/Boot/Sources/HEL/AMD64/BootJump.S b/Boot/Sources/HEL/AMD64/BootJump.S
index c2f03921..fc7b3c68 100644
--- a/Boot/Sources/HEL/AMD64/BootJump.S
+++ b/Boot/Sources/HEL/AMD64/BootJump.S
@@ -8,11 +8,12 @@
@brief this function setups a stack and then jumps to
a function */
rt_jump_to_address:
- mov rdx, rsp
- mov rdi, rcx
- mov rdx, rbp
+ mov r8, rsp
+
push rax
- mov r8, rcx
- call rdi
+ push rdx
+ jmp rcx
+ pop rdx
pop rax
+
ret
diff --git a/Boot/Sources/HEL/AMD64/BootMain.cxx b/Boot/Sources/HEL/AMD64/BootMain.cxx
index c786c16d..3cd6c0e3 100644
--- a/Boot/Sources/HEL/AMD64/BootMain.cxx
+++ b/Boot/Sources/HEL/AMD64/BootMain.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
------------------------------------------- */
@@ -10,24 +10,25 @@
#include <FirmwareKit/EFI.hxx>
#include <FirmwareKit/EFI/API.hxx>
#include <FirmwareKit/Handover.hxx>
-#include <KernelKit/MSDOS.hpp>
+#include <KernelKit/MSDOS.hxx>
#include <KernelKit/PE.hxx>
-#include <KernelKit/PEF.hpp>
+#include <KernelKit/PEF.hxx>
#include <NewKit/Macros.hpp>
-#include <NewKit/Ref.hpp>
+#include <NewKit/Ref.hxx>
+#include <BootKit/ProgramLoader.hxx>
#include <cstring>
-/// make the compiler shut up.
+// make the compiler shut up.
#ifndef kMachineModel
-#define kMachineModel "Zeta HD"
+#define kMachineModel "ZKA SSD"
#endif // !kMachineModel
#ifndef cExpectedWidth
-#define cExpectedWidth 436
+#define cExpectedWidth 1280
#endif
#ifndef cExpectedHeight
-#define cExpectedHeight 644
+#define cExpectedHeight 720
#endif
/** Graphics related. */
@@ -51,9 +52,14 @@ STATIC Void InitVideoFB() noexcept
BS->LocateProtocol(&kGopGuid, nullptr, (VoidPtr*)&kGop);
- for (size_t i = 0; i < kGop->Mode->MaxMode; ++i)
+ kStride = 4;
+
+ for (SizeT i = 0; i < kGop->Mode->MaxMode; ++i)
{
EfiGraphicsOutputProtocolModeInformation* infoPtr = nullptr;
+ UInt32 sz = 0U;
+
+ kGop->QueryMode(kGop, i, &sz, &infoPtr);
if (infoPtr->HorizontalResolution == cExpectedWidth &&
infoPtr->VerticalResolution == cExpectedHeight)
@@ -62,8 +68,6 @@ STATIC Void InitVideoFB() noexcept
break;
}
}
-
- kStride = 4;
}
/// @brief check the BootDevice if suitable.
@@ -88,18 +92,10 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
/// Splash screen stuff
- writer.Write(L"Zeta Electronics Corporation (R) newosldr: ")
+ writer.Write(L"ZKA Technologies (R) newosldr: ")
.Write(BVersionString::The())
.Write("\r");
-#ifndef __DEBUG__
- writer.Write(L"\rnewosldr: AMD64 is only supported in debug mode.\r");
-
- EFI::Stop();
-
- CANT_REACH();
-#endif
-
UInt32* MapKey = new UInt32();
UInt32* SizePtr = new UInt32();
EfiMemoryDescriptor* Descriptor = nullptr;
@@ -124,16 +120,20 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
vendorTable[4] == 'P' && vendorTable[5] == 'T' &&
vendorTable[6] == 'R' && vendorTable[7] == ' ')
{
- writer.Write(L"newosldr: Found ACPI RSD PTR!\r");
- handoverHdrPtr->f_HardwareTables.f_RsdPtr = (VoidPtr)vendorTable;
+ writer.Write(L"newosldr: Filling rsdptr...\r");
+ handoverHdrPtr->f_HardwareTables.f_VendorPtr = (VoidPtr)vendorTable;
break;
}
}
+ // Fill handover header now.
+
handoverHdrPtr->f_Magic = kHandoverMagic;
handoverHdrPtr->f_Version = kHandoverVersion;
+ // Provide fimware vendor name.
+
BCopyMem(handoverHdrPtr->f_FirmwareVendorName, SystemTable->FirmwareVendor,
handoverHdrPtr->f_FirmwareVendorLen);
@@ -144,58 +144,41 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
handoverHdrPtr->f_GOP.f_PixelFormat = kGop->Mode->Info->PixelFormat;
handoverHdrPtr->f_GOP.f_Size = kGop->Mode->FrameBufferSize;
- ///! Finally draw bootloader screen.
+ // Assign to global 'kHandoverHeader'.
kHandoverHeader = handoverHdrPtr;
- GXInit();
-
- GXDraw(RGB(9d, 9d, 9d), handoverHdrPtr->f_GOP.f_Height,
- handoverHdrPtr->f_GOP.f_Width, 0, 0);
-
- GXFini();
-
- GXDrawImg(NewBoot, NEWBOOT_HEIGHT, NEWBOOT_WIDTH,
- (handoverHdrPtr->f_GOP.f_Width - NEWBOOT_WIDTH) / 2,
- (handoverHdrPtr->f_GOP.f_Height - NEWBOOT_HEIGHT) / 2);
+ // check if we are running in the PC platform. If so abort.
+#if defined(__NEWOS_AMD64__) && !defined(__DEBUG__)
+ writer.Write(L"\rnewosldr: AMD64 support is not official.\r");
+ EFI::ThrowError(L"Beta-Software", L"Beta Software.");
+#endif
- GXFini();
+ // get memory map.
BS->GetMemoryMap(SizePtr, Descriptor, MapKey, SzDesc, RevDesc);
Descriptor = new EfiMemoryDescriptor[*SzDesc];
BS->GetMemoryMap(SizePtr, Descriptor, MapKey, SzDesc, RevDesc);
- writer.Write(L"Kernel-Desc-Count: ");
- writer.Write(*SzDesc);
- writer.Write(L"\r");
+ auto cDefaultMemoryMap = 0; // The sixth entry.
- auto cDefaultMemoryMap = 0; /// The sixth entry.
+ //-----------------------------------------------------------//
+ // A simple loop which finds a usable memory region for us.
+ //-----------------------------------------------------------//
- /// A simple loop which finds a usable memory region for us.
- SizeT i = 0UL;
- for (; Descriptor[i].Kind != EfiMemoryType::EfiConventionalMemory; ++i)
+ SizeT lookIndex = 0UL;
+
+ for (; Descriptor[lookIndex].Kind != EfiMemoryType::EfiConventionalMemory; ++lookIndex)
{
;
}
- cDefaultMemoryMap = i;
-
- writer.Write(L"Number-Of-Pages: ")
- .Write(Descriptor[cDefaultMemoryMap].NumberOfPages)
- .Write(L"\r");
- writer.Write(L"Virtual-Address: ")
- .Write(Descriptor[cDefaultMemoryMap].VirtualStart)
- .Write(L"\r");
- writer.Write(L"Phyiscal-Address: ")
- .Write(Descriptor[cDefaultMemoryMap].PhysicalStart)
- .Write(L"\r");
- writer.Write(L"Page-Kind: ")
- .Write(Descriptor[cDefaultMemoryMap].Kind)
- .Write(L"\r");
- writer.Write(L"Page-Attribute: ")
- .Write(Descriptor[cDefaultMemoryMap].Attribute)
- .Write(L"\r");
+ cDefaultMemoryMap = lookIndex;
+
+ //-----------------------------------------------------------//
+ // Update handover file specific table and phyiscal start field.
+ //-----------------------------------------------------------//
handoverHdrPtr->f_PhysicalStart =
(VoidPtr)Descriptor[cDefaultMemoryMap].PhysicalStart;
@@ -214,41 +197,18 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor);
- BFileReader reader(L"SplashScreen.fmt", ImageHandle);
- reader.ReadAll(512, 16);
-
- if (reader.Blob())
- {
- Char* buf = (Char*)reader.Blob();
-
- for (SizeT i = 0; i < reader.Size(); ++i)
- {
- if (buf[i] != '\n' && buf[i] != '\r')
- {
- if (buf[i] == '*')
- {
- writer.WriteCharacter('\t');
- }
- else
- {
- writer.WriteCharacter(buf[i]);
- }
- }
- else
- writer.Write(L"\r");
- }
- }
-
- ///
- /// The following checks for an exisiting partition
- /// inside the disk, if it doesn't have one,
- /// format the disk.
- //
+ // ---------------------------------------------------- //
+ // The following checks for an exisiting partition
+ // inside the disk, if it doesn't have one,
+ // format the disk.
+ // ---------------------------------------------------- //
BDiskFormatFactory<BootDeviceATA> diskFormatter;
- /// if not formated yet, then format it with the following folders:
- /// /, /Boot, /Applications.
+ // ---------------------------------------------------- //
+ // if not formated yet, then format it with the following folders:
+ // /, /Boot, /Applications.
+ // ---------------------------------------------------- //
if (!diskFormatter.IsPartitionValid())
{
BDiskFormatFactory<BootDeviceATA>::BFileDescriptor rootDesc{0};
@@ -259,10 +219,33 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
diskFormatter.Format(kMachineModel, &rootDesc, 1);
}
+#ifdef __NEWOS_OTA__
+
+ BFileReader readerKernel(L"newoskrnl.exe", ImageHandle);
+
+ readerKernel.ReadAll(0);
+
+ Boot::ProgramLoader* loader = nullptr;
+
+ if (readerKernel.Blob())
+ {
+ loader = new Boot::ProgramLoader(readerKernel.Blob());
+ loader->SetName("\"newoskrnl.exe\" (ZKA)");
+ }
+
+#endif // ifdef __NEWOS_OTA__
+
EFI::ExitBootServices(*MapKey, ImageHandle);
- /// Fallback to builtin kernel.
+ // ---------------------------------------------------- //
+ // Call OTA kernel or fallback to builtin.
+ // ---------------------------------------------------- //
+#ifdef __NEWOS_OTA__
+ if (loader)
+ loader->Start(handoverHdrPtr);
+#else
hal_init_platform(handoverHdrPtr);
+#endif // ifdef __NEWOS_OTA__
EFI::Stop();
diff --git a/Boot/Sources/HEL/AMD64/BootPlatform.cxx b/Boot/Sources/HEL/AMD64/BootPlatform.cxx
index e700a8de..58af5580 100644
--- a/Boot/Sources/HEL/AMD64/BootPlatform.cxx
+++ b/Boot/Sources/HEL/AMD64/BootPlatform.cxx
@@ -1,13 +1,12 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
------------------------------------------- */
#include <BootKit/Platform.hxx>
#include <BootKit/Protocol.hxx>
#include <BootKit/BootKit.hxx>
-#include "HALKit/AMD64/Processor.hpp"
#ifdef __STANDALONE__
@@ -94,6 +93,8 @@ EXTERN_C UInt32 In32(UInt16 port)
#else
+#include <HALKit/AMD64/Processor.hxx>
+
void rt_hlt()
{
Kernel::HAL::rt_halt();
diff --git a/Boot/Sources/HEL/AMD64/BootString.cxx b/Boot/Sources/HEL/AMD64/BootString.cxx
index f811130f..6fff3193 100644
--- a/Boot/Sources/HEL/AMD64/BootString.cxx
+++ b/Boot/Sources/HEL/AMD64/BootString.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
File: String.cxx
Purpose: NewBoot string library
diff --git a/Boot/Sources/HEL/AMD64/BootTextWriter.cxx b/Boot/Sources/HEL/AMD64/BootTextWriter.cxx
index 3006591a..7b0ab50c 100644
--- a/Boot/Sources/HEL/AMD64/BootTextWriter.cxx
+++ b/Boot/Sources/HEL/AMD64/BootTextWriter.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
File: String.cxx
Purpose: NewBoot string library
@@ -85,6 +85,36 @@ BTextWriter& BTextWriter::Write(const Char* str)
return *this;
}
+BTextWriter& BTextWriter::Write(const UChar* str)
+{
+#ifdef __DEBUG__
+ if (!str || *str == 0)
+ return *this;
+
+ CharacterTypeUTF16 strTmp[2];
+ strTmp[1] = 0;
+
+ for (size_t i = 0; str[i] != 0; i++)
+ {
+ if (str[i] == '\r')
+ {
+ strTmp[0] = str[i];
+ ST->ConOut->OutputString(ST->ConOut, strTmp);
+
+ strTmp[0] = '\n';
+ ST->ConOut->OutputString(ST->ConOut, strTmp);
+ }
+ else
+ {
+ strTmp[0] = str[i];
+ ST->ConOut->OutputString(ST->ConOut, strTmp);
+ }
+ }
+#endif // ifdef __DEBUG__
+
+ return *this;
+}
+
/**
@brief putc wrapper over EFI ConOut.
*/
@@ -131,9 +161,9 @@ BTextWriter& BTextWriter::_Write(const Long& x)
if (y < 0)
y = -y;
- const char NUMBERS[17] = "0123456789ABCDEF";
+ const char cNumbers[17] = "0123456789ABCDEF";
- this->WriteCharacter(NUMBERS[h]);
+ this->WriteCharacter(cNumbers[h]);
#endif // ifdef __DEBUG__
return *this;
diff --git a/Boot/Sources/HEL/AMD64/New+Delete.cxx b/Boot/Sources/HEL/AMD64/New+Delete.cxx
index 647cddb1..15903bb4 100644
--- a/Boot/Sources/HEL/AMD64/New+Delete.cxx
+++ b/Boot/Sources/HEL/AMD64/New+Delete.cxx
@@ -1,15 +1,15 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
------------------------------------------- */
#include <BootKit/Platform.hxx>
#include <BootKit/Protocol.hxx>
#include <BootKit/BootKit.hxx>
-#include <cstddef> /* Since we're using GCC for this EFI program. */
#ifdef __STANDALONE__
+#include <cstddef> /* Since we're using GCC for this EFI program. */
/// @brief Allocates a new object.
/// @param sz the size.
diff --git a/Boot/Sources/HEL/AMD64/Support.cxx b/Boot/Sources/HEL/AMD64/Support.cxx
index 8ebfb2ff..a2ac6394 100644
--- a/Boot/Sources/HEL/AMD64/Support.cxx
+++ b/Boot/Sources/HEL/AMD64/Support.cxx
@@ -1,12 +1,16 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
------------------------------------------- */
+#include <BootKit/BootKit.hxx>
+#include <FirmwareKit/EFI/API.hxx>
#include <FirmwareKit/EFI/EFI.hxx>
#include <FirmwareKit/Handover.hxx>
-#include <BootKit/Vendor/Support.hxx>
+#include <BootKit/Support.hxx>
+#include <KernelKit/MSDOS.hxx>
+#include <KernelKit/PE.hxx>
#ifdef __STANDALONE__
@@ -54,7 +58,7 @@ EXTERN_C size_t strlen(const char* whatToCheck)
return len;
}
-/// @brief somthing specific to the microsoft ABI, regarding checking the stack.
+/// @brief somthing specific to the Microsoft's ABI, When the stack grows too big.
EXTERN_C void ___chkstk_ms(void)
{
}
diff --git a/Boot/Sources/HEL/AMD64/compile_flags.txt b/Boot/Sources/HEL/AMD64/compile_flags.txt
index e4515efe..c24c4b09 100644
--- a/Boot/Sources/HEL/AMD64/compile_flags.txt
+++ b/Boot/Sources/HEL/AMD64/compile_flags.txt
@@ -1,3 +1,7 @@
-std=c++20
-I../../../
--I../../../../
+-I../../../../Kernel
+-D__NEWOS_AMD64__
+-std=c++20
+-D__x86_64__
+-D__NEWOS_OTA__
diff --git a/Boot/Sources/HEL/POWER/CoreBootStartup.S b/Boot/Sources/HEL/POWER/CoreBootStartup.S
index cff1add7..685dd836 100644
--- a/Boot/Sources/HEL/POWER/CoreBootStartup.S
+++ b/Boot/Sources/HEL/POWER/CoreBootStartup.S
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright Zeta Electronics Corporation
+ Copyright ZKA Technologies
------------------------------------------- */
diff --git a/Boot/Sources/ProgramLoader.cxx b/Boot/Sources/ProgramLoader.cxx
new file mode 100644
index 00000000..4ea0d4c6
--- /dev/null
+++ b/Boot/Sources/ProgramLoader.cxx
@@ -0,0 +1,115 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies
+
+------------------------------------------- */
+
+#include <BootKit/ProgramLoader.hxx>
+#include <BootKit/Support.hxx>
+#include <BootKit/BootKit.hxx>
+
+#include <KernelKit/PEF.hxx>
+#include <KernelKit/PE.hxx>
+#include <KernelKit/MSDOS.hxx>
+#include <CFKit/LoaderUtils.hxx>
+
+EXTERN_C
+{
+#include <string.h>
+}
+
+namespace Boot
+{
+ EXTERN_C Int32 rt_jump_to_address(HEL::HandoverProc baseCode, HEL::HandoverInformationHeader* handover, Char* stackPointer);
+
+ ProgramLoader::ProgramLoader(VoidPtr blob)
+ : fBlob(blob), fStartAddress(nullptr)
+ {
+ // detect the format.
+ const Char* firstBytes = reinterpret_cast<char*>(fBlob);
+
+ BTextWriter writer;
+
+ if (!firstBytes)
+ {
+ // failed to provide a valid pointer.
+ return;
+ }
+
+ if (firstBytes[0] == kMagMz0 &&
+ firstBytes[1] == kMagMz1)
+ {
+ writer.Write("newosldr: MZ executable detected.\r");
+
+ ExecHeaderPtr hdrPtr = (ldr_find_exec_header(firstBytes));
+ ExecOptionalHeaderPtr optHdr = (ldr_find_opt_exec_header(firstBytes));
+
+ // Parse PE32+
+ fStartAddress = (VoidPtr)((UIntPtr)optHdr->mImageBase + optHdr->mBaseOfCode + optHdr->mAddressOfEntryPoint);
+ fStackPtr = new Char[optHdr->mSizeOfStackReserve];
+
+ writer.Write("newosldr: Major Linker: ").Write(optHdr->mMajorLinkerVersion).Write("\r");
+ writer.Write("newosldr: Minor Linker: ").Write(optHdr->mMinorLinkerVersion).Write("\r");
+ writer.Write("newosldr: Major Subsystem: ").Write(optHdr->mMajorSubsystemVersion).Write("\r");
+ writer.Write("newosldr: Minor Subsystem: ").Write(optHdr->mMinorSubsystemVersion).Write("\r");
+ writer.Write("newosldr: Magic: ").Write(optHdr->mMagic).Write("\r");
+ writer.Write("newosldr: StartAddress: ").Write((UIntPtr)optHdr->mImageBase + optHdr->mBaseOfCode + optHdr->mAddressOfEntryPoint).Write("\r");
+ }
+ else if (firstBytes[0] == kPefMagic[0] &&
+ firstBytes[1] == kPefMagic[1] &&
+ firstBytes[2] == kPefMagic[2] &&
+ firstBytes[3] == kPefMagic[3])
+ {
+ // Parse Non FAT PEF.
+ fStartAddress = nullptr;
+ writer.Write("newosldr: PEF executable detected.\r");
+ }
+ else
+ {
+ writer.Write("newosldr: Exec format error.\r");
+ }
+ }
+
+ /// @note handover header has to be valid!
+ Void ProgramLoader::Start(HEL::HandoverInformationHeader* handover)
+ {
+ BTextWriter writer;
+
+ if (!handover ||
+ ((Char*)fStartAddress)[0] == 0x0)
+ {
+ writer.Write("newosldr: Exec format error.\r");
+ return;
+ }
+
+ writer.Write("newosldr: Trying to run: ").Write(fBlobName).Write("\r");
+
+ if (!fStartAddress)
+ {
+ HEL::HandoverProc fn = [](HEL::HandoverInformationHeader* rcx) -> void {
+ BTextWriter writer;
+ writer.Write("newosldr: Exec format error, Thread has been aborted.\r");
+
+ EFI::ThrowError(L"Exec-Format-Error", L"Format doesn't match (Thread aborted.)");
+ };
+
+ rt_jump_to_address(fn, handover, fStackPtr);
+
+ return;
+ }
+
+ HEL::HandoverProc start = reinterpret_cast<HEL::HandoverProc>((UIntPtr)fStartAddress);
+
+ rt_jump_to_address(start, handover, fStackPtr);
+ }
+
+ const Char* ProgramLoader::GetName()
+ {
+ return fBlobName;
+ }
+
+ Void ProgramLoader::SetName(const Char* name)
+ {
+ CopyMem(fBlobName, name, StrLen(name));
+ }
+} // namespace Boot
diff --git a/Boot/Sources/Root/SplashScreen.fmt b/Boot/Sources/Root/SplashScreen.fmt
deleted file mode 100644
index 4a851dc1..00000000
--- a/Boot/Sources/Root/SplashScreen.fmt
+++ /dev/null
@@ -1,7 +0,0 @@
-==================================================================
-Welcome to Zeta.
-Brought to you by: Amlal EL Mahrouss.
-* newosldr, newoskrnl: Amlal EL Mahrouss.
-
-Copyright Zeta Electronics Corporation, all rights reserved.
-==================================================================
diff --git a/Boot/Sources/Root/ZETA/BootLoader-Load.webm b/Boot/Sources/Root/ZETA/BootLoader-Load.webm
new file mode 100644
index 00000000..84b5e749
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/BootLoader-Load.webm
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-Black.ttf b/Boot/Sources/Root/ZETA/Urbanist-Black.ttf
new file mode 100644
index 00000000..e1ec32b3
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-Black.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-BlackItalic.ttf b/Boot/Sources/Root/ZETA/Urbanist-BlackItalic.ttf
new file mode 100644
index 00000000..85323c97
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-BlackItalic.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-Bold.ttf b/Boot/Sources/Root/ZETA/Urbanist-Bold.ttf
new file mode 100644
index 00000000..330e84f9
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-Bold.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-BoldItalic.ttf b/Boot/Sources/Root/ZETA/Urbanist-BoldItalic.ttf
new file mode 100644
index 00000000..08d47a8a
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-BoldItalic.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-ExtraBold.ttf b/Boot/Sources/Root/ZETA/Urbanist-ExtraBold.ttf
new file mode 100644
index 00000000..7971b6db
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-ExtraBold.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-ExtraBoldItalic.ttf b/Boot/Sources/Root/ZETA/Urbanist-ExtraBoldItalic.ttf
new file mode 100644
index 00000000..050297e2
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-ExtraBoldItalic.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-ExtraLight.ttf b/Boot/Sources/Root/ZETA/Urbanist-ExtraLight.ttf
new file mode 100644
index 00000000..a20a0bf9
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-ExtraLight.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-ExtraLightItalic.ttf b/Boot/Sources/Root/ZETA/Urbanist-ExtraLightItalic.ttf
new file mode 100644
index 00000000..68968472
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-ExtraLightItalic.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-Italic.ttf b/Boot/Sources/Root/ZETA/Urbanist-Italic.ttf
new file mode 100644
index 00000000..79688a6c
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-Italic.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-Light.ttf b/Boot/Sources/Root/ZETA/Urbanist-Light.ttf
new file mode 100644
index 00000000..59034000
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-Light.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-LightItalic.ttf b/Boot/Sources/Root/ZETA/Urbanist-LightItalic.ttf
new file mode 100644
index 00000000..1a455ce2
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-LightItalic.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-Medium.ttf b/Boot/Sources/Root/ZETA/Urbanist-Medium.ttf
new file mode 100644
index 00000000..e9a6dbb0
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-Medium.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-MediumItalic.ttf b/Boot/Sources/Root/ZETA/Urbanist-MediumItalic.ttf
new file mode 100644
index 00000000..44a9c897
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-MediumItalic.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-Regular.ttf b/Boot/Sources/Root/ZETA/Urbanist-Regular.ttf
new file mode 100644
index 00000000..2a794b27
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-Regular.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-SemiBold.ttf b/Boot/Sources/Root/ZETA/Urbanist-SemiBold.ttf
new file mode 100644
index 00000000..6d393d1c
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-SemiBold.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-SemiBoldItalic.ttf b/Boot/Sources/Root/ZETA/Urbanist-SemiBoldItalic.ttf
new file mode 100644
index 00000000..327aa044
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-SemiBoldItalic.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-Thin.ttf b/Boot/Sources/Root/ZETA/Urbanist-Thin.ttf
new file mode 100644
index 00000000..9e272162
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-Thin.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/Urbanist-ThinItalic.ttf b/Boot/Sources/Root/ZETA/Urbanist-ThinItalic.ttf
new file mode 100644
index 00000000..5cf054f1
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/Urbanist-ThinItalic.ttf
Binary files differ
diff --git a/Boot/Sources/Root/ZETA/fonts.json b/Boot/Sources/Root/ZETA/fonts.json
new file mode 100644
index 00000000..de0425a1
--- /dev/null
+++ b/Boot/Sources/Root/ZETA/fonts.json
@@ -0,0 +1,4 @@
+{
+ "font_ext": ".ttf",
+ "src_dir": "ZETA"
+}
diff --git a/Boot/Sources/Root/bootloader.json b/Boot/Sources/Root/bootloader.json
new file mode 100644
index 00000000..e8bc99fd
--- /dev/null
+++ b/Boot/Sources/Root/bootloader.json
@@ -0,0 +1,4 @@
+{
+ "newoskrnl.exe": "kernel",
+ "ZETA/fonts.json": "rsrc"
+}
diff --git a/Boot/Sources/compile_flags.txt b/Boot/Sources/compile_flags.txt
index c74d22b2..f9ca281f 100644
--- a/Boot/Sources/compile_flags.txt
+++ b/Boot/Sources/compile_flags.txt
@@ -1,4 +1,8 @@
-std=c++20
-I../
-I../../
+-I../../Kernel
-D__NEWOS_AMD64__
+-std=c++20
+-D__x86_64__
+-D__NEWOS_OTA__