diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-19 10:14:36 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-19 10:14:36 +0200 |
| commit | 933d1ef6721903895b15c45917a0fc705763fbf5 (patch) | |
| tree | 1aed4505be011528b6a9799bcd29bbc846eefb4a /dev/ZBA | |
| parent | da70596895d8135e08f8caac6978117697b4c021 (diff) | |
[IMP]
+ Fixed big parts of the user manager's code.
+ Fixed New FS kernel support.
+ Allocate 2GB of RAM for kernel.
- Reported bug to Jira regarding UserManager's TryLogin method.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZBA')
| -rw-r--r-- | dev/ZBA/BootKit/BootKit.hxx | 10 | ||||
| -rw-r--r-- | dev/ZBA/BootKit/Thread.hxx | 16 | ||||
| -rw-r--r-- | dev/ZBA/Sources/HEL/AMD64/BootJump.S | 28 | ||||
| -rw-r--r-- | dev/ZBA/Sources/HEL/AMD64/BootMain.cxx | 79 | ||||
| -rw-r--r-- | dev/ZBA/Sources/Thread.cxx | 10 |
5 files changed, 80 insertions, 63 deletions
diff --git a/dev/ZBA/BootKit/BootKit.hxx b/dev/ZBA/BootKit/BootKit.hxx index c0539133..c4d415f4 100644 --- a/dev/ZBA/BootKit/BootKit.hxx +++ b/dev/ZBA/BootKit/BootKit.hxx @@ -36,7 +36,7 @@ class BTextWriter; class BFileReader; -class BFileRunner; +class BThread; class BVersionString; typedef Char* PEFImagePtr; @@ -145,7 +145,7 @@ typedef UInt8* BlobType; class BVersionString final { public: - static const CharacterTypeUTF16* The() + static const CharacterTypeUTF8* The() { return BOOTLOADER_VERSION; } @@ -284,7 +284,8 @@ private: --partBlock.FreeCatalog; --partBlock.FreeSectors; - writer.Write(L"newosldr: root directory: ").Write(blob->fFileName).Write(L"\r"); + writer.Write(L"newosldr: Wrote directory: ").Write(blob->fFileName).Write(L"\r"); + writer.Write(L"newosldr: disk formatted.\r"); CopyMem(catalogKind->Name, blob->fFileName, StrLen(blob->fFileName)); @@ -373,9 +374,6 @@ inline Boolean BDiskFormatFactory<BootDev>::Format(const char* partName, CopyMem(epmBoot->Name, reinterpret_cast<VoidPtr>(const_cast<Char*>(cBlockName)), StrLen(cBlockName)); CopyMem(epmBoot->Magic, reinterpret_cast<VoidPtr>(const_cast<Char*>(kEPMMagic)), StrLen(kEPMMagic)); - BTextWriter writer; - writer.Write(L"newosldr: wrote partition with success.\r"); - fDiskDev.Leak().mBase = kEpmBase; fDiskDev.Leak().mSize = sectorSz; diff --git a/dev/ZBA/BootKit/Thread.hxx b/dev/ZBA/BootKit/Thread.hxx index 58b9683d..3946f6eb 100644 --- a/dev/ZBA/BootKit/Thread.hxx +++ b/dev/ZBA/BootKit/Thread.hxx @@ -14,20 +14,20 @@ namespace Boot { using namespace Kernel; - class Thread; + class BThread; /// @brief Program loader class /// @package nl.zeta.boot.api - class Thread final + class BThread final { public: - explicit Thread() = delete; - ~Thread() = default; + explicit BThread() = delete; + ~BThread() = default; - explicit Thread(Kernel::VoidPtr blob); + explicit BThread(Kernel::VoidPtr blob); - Thread& operator=(const Thread&) = default; - Thread(const Thread&) = default; + BThread& operator=(const BThread&) = default; + BThread(const BThread&) = default; void Start(HEL::HandoverInformationHeader* handover); const char* GetName(); @@ -35,7 +35,7 @@ namespace Boot bool IsValid(); private: - Char fBlobName[255] = { "Boot Thread" }; + Char fBlobName[255] = { "BootThread" }; VoidPtr fStartAddress{nullptr}; VoidPtr fBlob{nullptr}; }; diff --git a/dev/ZBA/Sources/HEL/AMD64/BootJump.S b/dev/ZBA/Sources/HEL/AMD64/BootJump.S index 7c2fcbc4..2eb745d0 100644 --- a/dev/ZBA/Sources/HEL/AMD64/BootJump.S +++ b/dev/ZBA/Sources/HEL/AMD64/BootJump.S @@ -1,4 +1,5 @@ .global rt_jump_to_address +.global rt_reset_hardware .text .text @@ -19,3 +20,30 @@ rt_jump_to_address: pop rax ret + +.code16 + +rt_reset_hardware: + /* dont raise any interrupts. (except ofc NMIs.) */ + cli +wait_gate1: + /* wait for gate 1 to be ready? */ + in al,0x64 + and al,2 + jnz wait_gate1 + mov al,0x0D1 + out 0x64,al +wait_gate2: + /* wait for gate 2 to be ready? */ + in al,0x64 + and al,2 + jnz wait_gate2 + mov al,0x0FE + out 0x60,al + + /* trigger triple fault */ + + xor eax,eax + mov cr3,eax +reset_wait: + jmp reset_wait diff --git a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx index a1d5ab07..1ecc7b4a 100644 --- a/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx +++ b/dev/ZBA/Sources/HEL/AMD64/BootMain.cxx @@ -38,7 +38,7 @@ STATIC EfiGraphicsOutputProtocol* kGop = nullptr; STATIC UInt16 kStride = 0U; STATIC EfiGUID kGopGuid; -EXTERN_C Void hal_init_platform(HEL::HandoverInformationHeader* HIH); +EXTERN_C Void rt_reset_hardware(); /** @brief Finds and stores the GOP. @@ -89,14 +89,6 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, InitEFI(SystemTable); ///! Init the EFI library. InitVideoFB(); ///! Init the GOP. - BTextWriter writer; - - /// Splash screen stuff - - writer.Write(L"ZKA Technologies (R) newosldr: ") - .Write(BVersionString::The()) - .Write("\r"); - UInt32 MapKey = 0; UInt32 SizePtr = sizeof(EfiMemoryDescriptor); EfiMemoryDescriptor* Descriptor = nullptr; @@ -118,13 +110,32 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, vendorTable[4] == 'P' && vendorTable[5] == 'T' && vendorTable[6] == 'R' && vendorTable[7] == ' ') { - writer.Write(L"newosldr: Filling RSD PTR...\r"); handoverHdrPtr->f_HardwareTables.f_VendorPtr = (VoidPtr)vendorTable; - break; } } + // ------------------------------------------ // + // draw background color. + // ------------------------------------------ // + + handoverHdrPtr->f_GOP.f_The = kGop->Mode->FrameBufferBase; + handoverHdrPtr->f_GOP.f_Width = kGop->Mode->Info->VerticalResolution; + handoverHdrPtr->f_GOP.f_Height = kGop->Mode->Info->HorizontalResolution; + handoverHdrPtr->f_GOP.f_PixelPerLine = kGop->Mode->Info->PixelsPerScanLine; + handoverHdrPtr->f_GOP.f_PixelFormat = kGop->Mode->Info->PixelFormat; + handoverHdrPtr->f_GOP.f_Size = kGop->Mode->FrameBufferSize; + + kHandoverHeader = handoverHdrPtr; + + CGInit(); + CGDrawInRegion(CGColor(0xff, 0x3a, 0x3a), handoverHdrPtr->f_GOP.f_Height, handoverHdrPtr->f_GOP.f_Width, 0, 0); + CGFini(); + + cg_write_text("NEWOSLDR (C) ZKA TECHNOLOGIES.", 10, 10, RGB(0xFF, 0xFF, 0xFF)); + cg_write_text(BVersionString::The(), 20, 10, RGB(0xFF, 0xFF, 0xFF)); + cg_write_text("WARNING: YOU MUST HAVE AT LEAST 2 CORES OR COHERENT PROCESSORS INSLATTED IN YOUR SYSTEM.", 30, 10, RGB(0xFF, 0xFF, 0xFF)); + // Fill handover header now. BS->GetMemoryMap(&SizePtr, Descriptor, &MapKey, &SzDesc, &RevDesc); @@ -164,6 +175,10 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, handoverHdrPtr->f_VirtualStart = (VoidPtr)Descriptor[cDefaultMemoryMap].VirtualStart; + handoverHdrPtr->f_HeapStart = nullptr; + + BS->AllocatePool(EfiLoaderCode, kHandoverHeapSz, &handoverHdrPtr->f_HeapStart); + handoverHdrPtr->f_VirtualSize = Descriptor[cDefaultMemoryMap].NumberOfPages; /* # of pages */ @@ -177,39 +192,23 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, BCopyMem(handoverHdrPtr->f_FirmwareVendorName, SystemTable->FirmwareVendor, handoverHdrPtr->f_FirmwareVendorLen); - handoverHdrPtr->f_GOP.f_The = kGop->Mode->FrameBufferBase; - handoverHdrPtr->f_GOP.f_Width = kGop->Mode->Info->VerticalResolution; - handoverHdrPtr->f_GOP.f_Height = kGop->Mode->Info->HorizontalResolution; - handoverHdrPtr->f_GOP.f_PixelPerLine = kGop->Mode->Info->PixelsPerScanLine; - handoverHdrPtr->f_GOP.f_PixelFormat = kGop->Mode->Info->PixelFormat; - handoverHdrPtr->f_GOP.f_Size = kGop->Mode->FrameBufferSize; - // Assign to global 'kHandoverHeader'. - kHandoverHeader = handoverHdrPtr; - - // ------------------------------------------ // - // draw background color. - // ------------------------------------------ // - - CGInit(); - CGDrawInRegion(CGColor(0xFF, 0xFF, 0xFF), handoverHdrPtr->f_GOP.f_Height, handoverHdrPtr->f_GOP.f_Width, 0, 0); - CGFini(); - BDiskFormatFactory<BootDeviceATA> checkPart; - + if (!checkPart.IsPartitionValid()) { - writer.Write("newosldr: Warning, partition isn't valid! repaired it.\rPlease restart the computer now.\r"); - BDiskFormatFactory<BootDeviceATA>::BFileDescriptor root; root.fFileName[0] = kNewFSRoot[0]; root.fFileName[1] = 0; root.fKind = kNewFSCatalogKindDir; - checkPart.Format("ZKA (C:)", &root, 1); + checkPart.Format("ZKA (A:)", &root, 1); + + cg_write_text("INSATLLED PARTITION WITH SUCCESS.", 40, 10, RGB(0xFF, 0xFF, 0xFF)); + rt_reset_hardware(); EFI::Stop(); } @@ -223,7 +222,7 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, readerKernel.ReadAll(0); - Boot::Thread* loader = nullptr; + Boot::BThread* loader = nullptr; // ------------------------------------------ // // If we succeed in reading the blob, then execute it. @@ -231,26 +230,18 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle, if (readerKernel.Blob()) { - loader = new Boot::Thread(readerKernel.Blob()); - loader->SetName("64-bit Kernel SMP DLL."); + loader = new Boot::BThread(readerKernel.Blob()); + loader->SetName("64-bit Kernel DLL."); } - writer.Write("newosldr: Running: ").Write(loader->GetName()).Write("\r"); - - /// TODO: Parse command line from ZKA\cmd.json - // CopyMem(handoverHdrPtr->f_CommandLine[0], "/SMP", StrLen("/SMP")); - handoverHdrPtr->f_FirmwareVendorLen = BStrLen(SystemTable->FirmwareVendor); EFI::ExitBootServices(MapKey, ImageHandle); // ---------------------------------------------------- // - // Call kernel. + // finally load kernel. // ---------------------------------------------------- // - cg_write_text("NEWOSLDR (C) ZKA TECHNOLOGIES.", 10, 10, RGB(0x00, 0x00, 0x00)); - cg_write_text("LOADING NEWOSKRNL...", 20, 10, RGB(0x00, 0x00, 0x00)); - loader->Start(handoverHdrPtr); EFI::Stop(); diff --git a/dev/ZBA/Sources/Thread.cxx b/dev/ZBA/Sources/Thread.cxx index 5bd18b19..c13d25b9 100644 --- a/dev/ZBA/Sources/Thread.cxx +++ b/dev/ZBA/Sources/Thread.cxx @@ -26,7 +26,7 @@ EXTERN EfiBootServices* BS; namespace Boot { - Thread::Thread(VoidPtr blob) + BThread::BThread(VoidPtr blob) : fBlob(blob), fStartAddress(nullptr) { // detect the format. @@ -138,7 +138,7 @@ namespace Boot } /// @note handover header has to be valid! - Void Thread::Start(HEL::HandoverInformationHeader* handover) + Void BThread::Start(HEL::HandoverInformationHeader* handover) { BTextWriter writer; @@ -162,17 +162,17 @@ namespace Boot err_fn(handover); } - const Char* Thread::GetName() + const Char* BThread::GetName() { return fBlobName; } - Void Thread::SetName(const Char* name) + Void BThread::SetName(const Char* name) { CopyMem(fBlobName, name, StrLen(name)); } - bool Thread::IsValid() + bool BThread::IsValid() { return fStartAddress != nullptr; } |
