diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-02 11:58:14 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-02 11:58:14 +0100 |
| commit | 1b4bd4df5f5cc15c688a13a169a76a8af69d0700 (patch) | |
| tree | 66c8052ede212f0ec3d383661739af1bc6ee4432 /Private/NewBoot/Source | |
| parent | df77fd9586cb305a738d5b4dfcdbe67177e3de3f (diff) | |
Bootloader: Getting it done now.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot/Source')
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/ATA.cxx | 22 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootKit.cxx | 40 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx | 3 | ||||
| -rw-r--r-- | Private/NewBoot/Source/makefile | 1 |
4 files changed, 44 insertions, 22 deletions
diff --git a/Private/NewBoot/Source/HEL/AMD64/ATA.cxx b/Private/NewBoot/Source/HEL/AMD64/ATA.cxx index 4f1b3171..c289bcf5 100644 --- a/Private/NewBoot/Source/HEL/AMD64/ATA.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/ATA.cxx @@ -114,9 +114,7 @@ Void ATAReadLba(UInt32 Lba, UInt8 Bus, Boolean Master, CharacterType* Buf, ATAPoll(IO); - for (SizeT index = 0UL; index < 256; ++index) { - Buf[index + Offset] = In16(IO + ATA_REG_DATA); - } + Buf[Offset] = In16(IO + ATA_REG_DATA); ATAWait(IO); } @@ -140,13 +138,13 @@ Void ATAWriteLba(UInt32 Lba, UInt8 Bus, Boolean Master, wchar_t* Buf, ATAPoll(IO); - for (SizeT index = 0UL; index < 256; ++index) { - Out16(IO + ATA_REG_DATA, Buf[index + Offset]); - } + Out16(IO + ATA_REG_DATA, Buf[Offset]); ATAWait(IO); } +Boolean ATAIsDetected(Void) { return kATADetected; } + /*** * * @@ -155,10 +153,8 @@ Void ATAWriteLba(UInt32 Lba, UInt8 Bus, Boolean Master, wchar_t* Buf, * */ -Boolean ATAIsDetected(Void) { return kATADetected; } - /** - * @brief Init ATA driver. + * @brief ATA Device constructor. * @param void none. */ BATADevice::BATADevice() noexcept { @@ -189,13 +185,9 @@ BATADevice& BATADevice::Read(CharacterType* Buf, const SizeT& Sz) { if (!Buf || Sz < 1) return *this; - SizeT Off = 0; - for (SizeT i = 0UL; i < Sz; ++i) { ATAReadLba(this->Leak().mBase + i, this->Leak().mBus, this->Leak().mMaster, - Buf, Off); - - Off += 512; + Buf, i); } return *this; @@ -217,7 +209,7 @@ BATADevice& BATADevice::Write(CharacterType* Buf, const SizeT& Sz) { ATAWriteLba(this->Leak().mBase + i, this->Leak().mBus, this->Leak().mMaster, Buf, Off); - Off += 512; + Off += kATASectorSz; } return *this; diff --git a/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx b/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx index 99f8d41b..600a8fcc 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx @@ -9,10 +9,27 @@ #include <BootKit/BootKit.hxx> #include <EFIKit/Api.hxx> +#include <FSKit/NewFS.hxx> /// bugs 0 +///////////////////////////////////////////////////////////////////////////////////////////////////////// + +HCore::SizeT BCopyMem(CharacterType *dest, CharacterType *src, + const HCore::SizeT len) { + if (!dest || !src) return 0; + + SizeT index = 0UL; + for (; index < len; ++index) { + dest[index] = src[index]; + } + + return index; +} + HCore::SizeT BStrLen(const CharacterType *ptr) { + if (!ptr) return 0; + HCore::SizeT cnt = 0; while (*ptr != (CharacterType)0) { @@ -23,12 +40,10 @@ HCore::SizeT BStrLen(const CharacterType *ptr) { return cnt; } -/** - @biref set memory -*/ - HCore::SizeT BSetMem(CharacterType *src, const CharacterType byte, const HCore::SizeT len) { + if (!src) return 0; + HCore::SizeT cnt = 0UL; while (*src != 0) { @@ -43,9 +58,8 @@ HCore::SizeT BSetMem(CharacterType *src, const CharacterType byte, return cnt; } -/** -@brief puts wrapper over VGA. -*/ +///////////////////////////////////////////////////////////////////////////////////////////////////////// + BTextWriter &BTextWriter::WriteString(const CharacterType *str) { if (*str == 0 || !str) return *this; @@ -66,6 +80,9 @@ BTextWriter &BTextWriter::WriteCharacter(CharacterType c) { return *this; } +///////////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////////// + /*** @brief File Reader constructor. */ @@ -89,5 +106,14 @@ HCore::VoidPtr BFileReader::ReadAll() { .WriteString(mPath) .WriteString(L" *** \r\n"); + EfiFileDevicePathProtocol loadFile{0}; + loadFile.LengthData[0] = 0xFF; + loadFile.LengthData[1] = 0; + + loadFile.Type = kEFIMediaDevicePath; + loadFile.SubType = 0; // from all drives. + + BCopyMem(loadFile.Path, mPath, kPathLen); + return nullptr; } diff --git a/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx b/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx index 69f235c4..8dfd7a71 100644 --- a/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx @@ -7,6 +7,7 @@ * ======================================================== */ +#include "NewKit/Defines.hpp" #define __BOOTLOADER__ 1 #include <BootKit/BootKit.hxx> @@ -33,6 +34,8 @@ EFI_EXTERN_C int EfiMain(EfiHandlePtr ImageHandle, KeRuntimeStop(L"HCoreLdr_NoSuchKernel", L"Couldn't find HCoreKrnl.exe! Aborting..."); + writer.WriteString(L"HCoreLdr: Running HCoreKrnl.exe...\r\n"); + EFI::ExitBootServices(SystemTable, mapKey, ImageHandle); EFI::Stop(); diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile index 063fa42a..0f679772 100644 --- a/Private/NewBoot/Source/makefile +++ b/Private/NewBoot/Source/makefile @@ -17,6 +17,7 @@ bootloader-amd64: $(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx $(LD_GNU) *.o -e efi_main -filealign:16 -shared --subsystem=10 -ffreestanding -o HCoreLdr.exe cp HCoreLdr.exe CDROM/EFI/BOOT/BOOTX64.EFI + cp ../../HCoreKrnl.exe CDROM/EFI/BOOT/HCoreKrnl.exe .PHONY: run-efi-debug run-efi-debug: |
