diff options
Diffstat (limited to 'Private/NewBoot')
| -rw-r--r-- | Private/NewBoot/BootKit/BootKit.hxx | 44 | ||||
| -rw-r--r-- | Private/NewBoot/CxxRuntime/unwind.cxx | 11 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootKit.cxx | 28 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx | 33 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/Platform.cxx | 4 | ||||
| -rw-r--r-- | Private/NewBoot/Source/makefile | 4 |
6 files changed, 31 insertions, 93 deletions
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx index 70607a9c..9c0ec863 100644 --- a/Private/NewBoot/BootKit/BootKit.hxx +++ b/Private/NewBoot/BootKit/BootKit.hxx @@ -18,7 +18,8 @@ using namespace HCore; -typedef void *PEFImage; +typedef VoidPtr PEFImagePtr; +typedef VoidPtr PEImagePtr; enum { kSegmentCode = 2, @@ -26,50 +27,27 @@ enum { kSegmentBss = 6, }; +typedef wchar_t CharacterType; + /** * @brief BootKit Text Writer class * Writes to VGA. */ -class BKTextWriter final { - volatile UInt16 *fWhere{nullptr}; - +class BTextWriter final { public: - void WriteString(const char *c, unsigned char forecolour, - unsigned char backcolour, int x, int y); + void WriteString(const CharacterType *str); - void WriteCharacter(char c, unsigned char forecolour, - unsigned char backcolour, int x, int y); + void WriteCharacter(CharacterType c); public: - BKTextWriter() = default; - ~BKTextWriter() = default; + BTextWriter() = default; + ~BTextWriter() = default; public: - BKTextWriter &operator=(const BKTextWriter &) = default; - BKTextWriter(const BKTextWriter &) = default; -}; - -enum { - kBlack, - kBlue, - kGreen, - kCyan, - kRed, - kMagenta, - kBrown, - kLightGray, - kDarkGray, - kLightBlue, - kLightGreen, - kLightCyan, - kLightRed, - kLightMagenta, - kYellow, - kWhite, + BTextWriter &operator=(const BTextWriter &) = default; + BTextWriter(const BTextWriter &) = default; }; -#define BK_START_KERNEL (0x8000000) - HCore::SizeT BStrLen(const char *ptr); HCore::SizeT BSetMem(char *src, const char byte, const HCore::SizeT len); diff --git a/Private/NewBoot/CxxRuntime/unwind.cxx b/Private/NewBoot/CxxRuntime/unwind.cxx index acfc0b6b..f679bdd5 100644 --- a/Private/NewBoot/CxxRuntime/unwind.cxx +++ b/Private/NewBoot/CxxRuntime/unwind.cxx @@ -1,11 +1,8 @@ -namespace cxxkit -{ +namespace cxxkit { ///! @brief C++ ABI unwinding ///! finis array (r1) ///! n of finis (r2) -extern "C" void __unwind(void (**finis)(void), int cnt) -{ - for (int i = 0; i < cnt; ++i) - (finis[i])(); +extern "C" void __unwind(void (**finis)(void), int cnt) { + for (int i = 0; i < cnt; ++i) (finis[i])(); } -} // namespace cxxkit +} // namespace cxxkit diff --git a/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx b/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx index 68971e0c..19df55b0 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx @@ -8,8 +8,9 @@ */ #include <BootKit/BootKit.hxx> +#include <EFIKit/EFILib.hxx> -constexpr HCore::UInt32 kVGABaseAddress = 0xb8000; +#include "EFIKit/EFI.hxx" HCore::SizeT BStrLen(const char *ptr) { long long int cnt = 0; @@ -40,29 +41,18 @@ HCore::SizeT BSetMem(char *src, const char byte, const HCore::SizeT len) { /** @brief puts wrapper over VGA. */ -void BKTextWriter::WriteString(const char *str, unsigned char forecolour, - unsigned char backcolour, int x, int y) { +void BTextWriter::WriteString(const CharacterType *str) { if (*str == 0 || !str) return; - for (SizeT idx = 0; idx < BStrLen(str); ++idx) { - this->WriteCharacter(str[idx], forecolour, backcolour, x, y); - ++x; - } + ST->ConOut->OutputString(ST->ConOut, str); } /** @brief putc wrapper over VGA. */ -void BKTextWriter::WriteCharacter(char c, unsigned char forecolour, - unsigned char backcolour, int x, int y) { - UInt16 attrib = (backcolour << 4) | (forecolour & 0x0F); - - // Video Graphics Array - // Reads at kVGABaseAddress - // Decodes UInt16, gets attributes (back colour, fore colour) - // Gets character, send it to video display with according colour in the - // registry. - - fWhere = (volatile UInt16 *)kVGABaseAddress + (y * 80 + x); - *fWhere = c | (attrib << 8); +void BTextWriter::WriteCharacter(CharacterType c) { + EfiCharType str[2]; + str[0] = c; + str[1] = 0; + ST->ConOut->OutputString(ST->ConOut, str); } diff --git a/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx b/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx index b3e63bd9..89b3ece2 100644 --- a/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx @@ -18,38 +18,11 @@ EFI_EXTERN_C int EfiMain(EfiHandlePtr ImageHandle, EfiSystemTable* SystemTable) { KeInitEFI(SystemTable); - SystemTable->ConOut->OutputString(SystemTable->ConOut, - L"HCoreLdr: Initializing...\r\n"); - - EfiLoadImageProtocol* protocol = nullptr; - EfiGUID guid = EFI_LOADED_IMAGE_PROTOCOL_GUID; - - Int32 statusCode = SystemTable->BootServices->OpenProtocol( - ImageHandle, &guid, (VoidPtr*)&protocol, ImageHandle, nullptr, - EFI_OPEN_PROTOCOL_GET_PROTOCOL); - - if (statusCode != kEfiOk) { - SystemTable->ConOut->OutputString( - SystemTable->ConOut, - L"HCoreLdr: Could not locate EfiLoadImageProtocol! Aborting...\r\n"); - - Detail::Stop(SystemTable); - return kEfiFail; - } - - SystemTable->BootServices->OpenProtocol( - ImageHandle, &guid, (VoidPtr*)&protocol, ImageHandle, ImageHandle, - EFI_OPEN_PROTOCOL_GET_PROTOCOL); - - if (SystemTable->BootServices->ExitBootServices(ImageHandle, 0) != kEfiOk) { - SystemTable->ConOut->OutputString( - SystemTable->ConOut, L"HCoreLdr: Could not exit Boot Services!\r\n"); - - Detail::Stop(SystemTable); - } + BTextWriter writer; + writer.WriteString(L"HCoreLdr: Booting from disk...\r\n"); // TODO: Jump Code - Detail::Stop(SystemTable); + EFI::Stop(SystemTable); return kEfiOk; } diff --git a/Private/NewBoot/Source/HEL/AMD64/Platform.cxx b/Private/NewBoot/Source/HEL/AMD64/Platform.cxx index a0c93ab5..f72e0be1 100644 --- a/Private/NewBoot/Source/HEL/AMD64/Platform.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/Platform.cxx @@ -9,8 +9,8 @@ /* * - * @file Processor.cxx - * @brief Processor Specific Functions. + * @file Platform.cxx + * @brief Platform Specific Functions. * */ diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile index 2e092da2..74ab7878 100644 --- a/Private/NewBoot/Source/makefile +++ b/Private/NewBoot/Source/makefile @@ -12,8 +12,8 @@ FLAG_GNU=-fshort-wchar -fPIC -D__DBG__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I. invalid-recipe: @echo "invalid-recipe: Use make arch-<arch> all instead." -.PHONY: arch-amd64 -arch-amd64: +.PHONY: bootloader-amd64 +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 |
