diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-04 14:16:39 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-04 14:16:39 +0200 |
| commit | a38083f7d528111087949a0ba8e3970f091f2fc9 (patch) | |
| tree | c21cda9b4571758540564b562ea6858ddf89030b /Boot | |
| parent | cd400898f5a6ef04690231323c0be107ae330fb4 (diff) | |
[FIX] CG's text writer functions. Need to fix ProgramLoader class now
for DLLs/LIBs.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Boot')
| -rw-r--r-- | Boot/BootKit/BootKit.hxx | 2 | ||||
| -rw-r--r-- | Boot/Sources/HEL/AMD64/BootMain.cxx | 78 | ||||
| -rw-r--r-- | Boot/Sources/HEL/AMD64/Support.cxx | 6 | ||||
| -rw-r--r-- | Boot/Sources/ProgramLoader.cxx | 9 | ||||
| -rw-r--r-- | Boot/amd64-efi.make | 2 |
5 files changed, 20 insertions, 77 deletions
diff --git a/Boot/BootKit/BootKit.hxx b/Boot/BootKit/BootKit.hxx index e87d87b1..9bc915b2 100644 --- a/Boot/BootKit/BootKit.hxx +++ b/Boot/BootKit/BootKit.hxx @@ -382,7 +382,7 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const char* partName, CopyMem(epmBoot->Magic, reinterpret_cast<VoidPtr>(const_cast<Char*>(kEPMMagic)), StrLen(kEPMMagic)); BTextWriter writer; - writer.Write(L"newosldr: wrote parition.\r"); + writer.Write(L"newosldr: wrote partition.\r"); fDiskDev.Leak().mBase = kEpmBase; fDiskDev.Leak().mSize = sectorSz; diff --git a/Boot/Sources/HEL/AMD64/BootMain.cxx b/Boot/Sources/HEL/AMD64/BootMain.cxx index 3f71d995..0c0c9953 100644 --- a/Boot/Sources/HEL/AMD64/BootMain.cxx +++ b/Boot/Sources/HEL/AMD64/BootMain.cxx @@ -149,55 +149,6 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, kHandoverHeader = handoverHdrPtr; - // 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 - - // get memory map. - - BS->GetMemoryMap(SizePtr, Descriptor, MapKey, SzDesc, RevDesc); - - Descriptor = new EfiMemoryDescriptor[*SzDesc]; - BS->GetMemoryMap(SizePtr, Descriptor, MapKey, SzDesc, RevDesc); - - auto cDefaultMemoryMap = 0; // The sixth entry. - - //-----------------------------------------------------------// - // A simple loop which finds a usable memory region for us. - //-----------------------------------------------------------// - - SizeT lookIndex = 0UL; - - for (; Descriptor[lookIndex].Kind != EfiMemoryType::EfiConventionalMemory; ++lookIndex) - { - ; - } - - cDefaultMemoryMap = lookIndex; - - //-----------------------------------------------------------// - // Update handover file specific table and phyiscal start field. - //-----------------------------------------------------------// - - handoverHdrPtr->f_PhysicalStart = - (VoidPtr)Descriptor[cDefaultMemoryMap].PhysicalStart; - - handoverHdrPtr->f_FirmwareSpecific[HEL::kHandoverSpecificAttrib] = - Descriptor[cDefaultMemoryMap].Attribute; - handoverHdrPtr->f_FirmwareSpecific[HEL::kHandoverSpecificKind] = - Descriptor[cDefaultMemoryMap].Kind; - handoverHdrPtr->f_FirmwareSpecific[HEL::kHandoverSpecificMemoryEfi] = - (UIntPtr)Descriptor; - - handoverHdrPtr->f_VirtualStart = - (VoidPtr)Descriptor[cDefaultMemoryMap].VirtualStart; - handoverHdrPtr->f_VirtualSize = - Descriptor[cDefaultMemoryMap].NumberOfPages; /* # of pages */ - - handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor); - // ------------------------------------------ // // draw background color. // ------------------------------------------ // @@ -206,28 +157,18 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, CGDrawInRegion(CGColor(0xFF, 0xFF, 0xFF), handoverHdrPtr->f_GOP.f_Height, handoverHdrPtr->f_GOP.f_Width, 0, 0); CGFini(); + // 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 + // ---------------------------------------------------- // // 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 (!diskFormatter.IsPartitionValid()) - { - BDiskFormatFactory<BootDeviceATA>::BFileDescriptor rootDesc{0}; - - CopyMem(rootDesc.fFileName, kNewFSRoot, StrLen(kNewFSRoot)); - rootDesc.fKind = kNewFSCatalogKindDir; - - diskFormatter.Format(kMachineModel, &rootDesc, 1); - } - BFileReader readerKernel(L"newoskrnl.dll", ImageHandle); readerKernel.ReadAll(0); @@ -241,20 +182,23 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, if (readerKernel.Blob()) { loader = new Boot::ProgramLoader(readerKernel.Blob()); - loader->SetName("\"newoskrnl.dll\" (64-bit SMP)"); + loader->SetName("\"newoskrnl.dll\" (64-bit SMP DLL)"); } writer.Write("newosldr: Running: ").Write(loader->GetName()).Write("\r"); CopyMem(handoverHdrPtr->f_CommandLine[0], "/SMP", StrLen("/SMP")); + handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor); + EFI::ExitBootServices(*MapKey, ImageHandle); // ---------------------------------------------------- // // Call kernel. // ---------------------------------------------------- // - cg_write_text((UInt8*)"NEWOSKRNL", 0, 0, RGB(0x10, 0x10, 0x10)); + cg_write_text("NEWOSLDR (C) ZKA TECHNOLOGIES.", 10, 10, RGB(0x00, 0x00, 0x00)); + cg_write_text("SMP OS (MAX 8 CORES).", 20, 10, RGB(0x00, 0x00, 0x00)); loader->Start(handoverHdrPtr); diff --git a/Boot/Sources/HEL/AMD64/Support.cxx b/Boot/Sources/HEL/AMD64/Support.cxx index eb6f54df..a2ac6394 100644 --- a/Boot/Sources/HEL/AMD64/Support.cxx +++ b/Boot/Sources/HEL/AMD64/Support.cxx @@ -14,12 +14,6 @@ #ifdef __STANDALONE__ -EXTERN_C void __cxa_pure_virtual() -{ - BTextWriter writer; - writer.Write("newosldr: Placeholder.\r"); -} - /// @brief memset definition in C++. /// @param dst destination pointer. /// @param byte value to fill in. diff --git a/Boot/Sources/ProgramLoader.cxx b/Boot/Sources/ProgramLoader.cxx index be2650dc..e4f61630 100644 --- a/Boot/Sources/ProgramLoader.cxx +++ b/Boot/Sources/ProgramLoader.cxx @@ -56,11 +56,16 @@ namespace Boot writer.Write("newosldr: Major Subsystem Ver: ").Write(optHdr->mMajorSubsystemVersion).Write("\r"); writer.Write("newosldr: Minor Subsystem Ver: ").Write(optHdr->mMinorSubsystemVersion).Write("\r"); writer.Write("newosldr: Magic: ").Write(optHdr->mMagic).Write("\r"); + writer.Write("newosldr: ImageBase: ").Write(optHdr->mImageBase).Write("\r"); - ExecSectionHeaderPtr sectPtr = (ExecSectionHeaderPtr)((UIntPtr)firstBytes + ((DosHeaderPtr)firstBytes)->eLfanew + hdrPtr->mSizeOfOptionalHeader + sizeof(ExecHeader) + sizeof(UInt32)); + EfiPhysicalAddress base_img_addr = optHdr->mImageBase; constexpr auto cMaxSectionsOfKernel = 10; + BS->AllocatePages(EfiAllocateType::AllocateAnyPages, EfiMemoryType::EfiLoaderCode, cMaxSectionsOfKernel, &base_img_addr); + + ExecSectionHeaderPtr sectPtr = (ExecSectionHeaderPtr)((UIntPtr)firstBytes + ((DosHeaderPtr)firstBytes)->eLfanew + hdrPtr->mSizeOfOptionalHeader + sizeof(ExecHeader) + sizeof(UInt32)); + for (SizeT sectIndex = 0; sectIndex < cMaxSectionsOfKernel; ++sectIndex) { ExecSectionHeaderPtr sect = §Ptr[sectIndex]; @@ -72,7 +77,7 @@ namespace Boot { if (!fStartAddress) { - fStartAddress = (VoidPtr)((VoidPtr)((UIntPtr)fBlob + 184 + (sect->mVirtualAddress - optHdr->mAddressOfEntryPoint))); + fStartAddress = (VoidPtr)((VoidPtr)((UIntPtr)sect->mPointerToRawData + (sect->mVirtualAddress - optHdr->mAddressOfEntryPoint))); writer.Write("newosldr: Start Address set: ").Write((UIntPtr)fStartAddress).Write("\r"); } diff --git a/Boot/amd64-efi.make b/Boot/amd64-efi.make index c33ccc96..f11d68e3 100644 --- a/Boot/amd64-efi.make +++ b/Boot/amd64-efi.make @@ -45,7 +45,7 @@ REM=rm REM_FLAG=-f FLAG_ASM=-f win64 -FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -D__NEWOS_OTA__ -mno-red-zone -D__KERNEL__ -D__NEWBOOT__ \ +FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -D__NEWOS_OTA__ -mno-red-zone -D__NEWOSKRNL__ -D__NEWOSLDR__ \ -DEFI_FUNCTION_WRAPPER -I./ -I../Vendor -I../Kernel -c -nostdlib -fno-rtti -fno-exceptions \ -std=c++20 -D__HAVE_MAHROUSS_APIS__ -D__NEWOS_AMD64__ -D__MAHROUSS__ -D__BOOTLOADER__ -I../ |
