summaryrefslogtreecommitdiffhomepage
path: root/Private
diff options
context:
space:
mode:
Diffstat (limited to 'Private')
-rw-r--r--Private/FirmwareKit/CoreBoot/.gitkeep0
-rw-r--r--Private/FirmwareKit/EFI/API.hxx4
-rw-r--r--Private/HALKit/AMD64/HalKernelMain.cxx1
-rw-r--r--Private/NewBoot/BootKit/BootKit.hxx2
-rw-r--r--Private/NewBoot/Source/CDROM/SplashScreen.fmt6
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx26
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/BootMain.cxx40
-rw-r--r--Private/NewBoot/Source/makefile20
-rw-r--r--Private/Source/AppMain.cxx1
-rw-r--r--Private/makefile9
10 files changed, 88 insertions, 21 deletions
diff --git a/Private/FirmwareKit/CoreBoot/.gitkeep b/Private/FirmwareKit/CoreBoot/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Private/FirmwareKit/CoreBoot/.gitkeep
diff --git a/Private/FirmwareKit/EFI/API.hxx b/Private/FirmwareKit/EFI/API.hxx
index cfb3f425..138d6b42 100644
--- a/Private/FirmwareKit/EFI/API.hxx
+++ b/Private/FirmwareKit/EFI/API.hxx
@@ -19,7 +19,7 @@ EXTERN_C void rt_hlt();
namespace EFI {
/// @brief Halt and clear interrupts.
-/// @return
+/// @return
inline Void Stop() noexcept {
while (1) {
rt_hlt();
@@ -51,7 +51,7 @@ inline UInt32 Platform() noexcept { return kPEMachineAMD64; }
*/
inline void RaiseHardError(const EfiCharType *ErrorCode,
const EfiCharType *Reason) noexcept {
- ST->ConOut->OutputString(ST->ConOut, L"*** STOP ***\r\n");
+ ST->ConOut->OutputString(ST->ConOut, L"\r\n*** STOP ***\r\n");
ST->ConOut->OutputString(ST->ConOut, L"*** Error: ");
ST->ConOut->OutputString(ST->ConOut, ErrorCode);
diff --git a/Private/HALKit/AMD64/HalKernelMain.cxx b/Private/HALKit/AMD64/HalKernelMain.cxx
index 13d040b5..57c37778 100644
--- a/Private/HALKit/AMD64/HalKernelMain.cxx
+++ b/Private/HALKit/AMD64/HalKernelMain.cxx
@@ -5,7 +5,6 @@
------------------------------------------- */
#include <ArchKit/ArchKit.hpp>
-#include <Builtins/Toolbox/Rsrc/Splash.rsrc>
#include <Builtins/Toolbox/Toolbox.hxx>
#include <FirmwareKit/Handover.hxx>
#include <KernelKit/FileManager.hpp>
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx
index 3793e481..117e32df 100644
--- a/Private/NewBoot/BootKit/BootKit.hxx
+++ b/Private/NewBoot/BootKit/BootKit.hxx
@@ -103,7 +103,7 @@ class BFileReader final {
~BFileReader();
public:
- Void ReadAll();
+ Void ReadAll(SizeT until, SizeT chunk = 4096);
enum {
kOperationOkay,
diff --git a/Private/NewBoot/Source/CDROM/SplashScreen.fmt b/Private/NewBoot/Source/CDROM/SplashScreen.fmt
new file mode 100644
index 00000000..e47a66a6
--- /dev/null
+++ b/Private/NewBoot/Source/CDROM/SplashScreen.fmt
@@ -0,0 +1,6 @@
+Welcome to NeWS
+
+Brought to you by:
+* MicroKernel, Bootloader: Amlal EL Mahrouss.
+
+Copyright Mahrouss-Logic, all rights reserved.
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx b/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
index 0046698c..3a445d61 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootFileReader.cxx
@@ -96,13 +96,11 @@ BFileReader::~BFileReader() {
/**
@brief this reads all of the buffer.
- @param ImageHandle used internally.
+ @param until read until size is reached.
*/
-Void BFileReader::ReadAll() {
- if (this->mErrorCode != kOperationOkay) return;
-
+Void BFileReader::ReadAll(SizeT until, SizeT chunk) {
if (mBlob == nullptr) {
- if (auto err = BS->AllocatePool(EfiLoaderCode, mSizeFile,
+ if (auto err = BS->AllocatePool(EfiLoaderCode, until,
(VoidPtr*)&mBlob) != kEfiOk) {
mWriter.Write(L"*** EFI-Code: ").Write(err).Write(L" ***\r\n");
EFI::RaiseHardError(L"NewBoot_PageError", L"Allocation error.");
@@ -111,9 +109,23 @@ Void BFileReader::ReadAll() {
mErrorCode = kNotSupported;
- if (mFile->Read(mFile, &mSizeFile, (VoidPtr)((UIntPtr)mBlob)) != kEfiOk)
- return;
+ UInt64 bufSize = chunk;
+ UInt64 szCnt = 0;
+ UInt64 curSz = 0;
+
+ while (curSz < until) {
+ if (mFile->Read(mFile, &bufSize, (VoidPtr)((UIntPtr)mBlob + curSz)) != kEfiOk) {
+ break;
+ }
+
+ szCnt += bufSize;
+ curSz += bufSize;
+
+ if (bufSize == 0)
+ break;
+ }
+ mSizeFile = curSz;
mErrorCode = kOperationOkay;
}
diff --git a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
index 21b1505a..638fe37a 100644
--- a/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/BootMain.cxx
@@ -121,11 +121,14 @@ EFI_EXTERN_C EFI_API Int Main(EfiHandlePtr ImageHandle,
ToolboxInitRsrc();
- ToolboxDrawZone(RGB(FF, FF, FF), handoverHdrPtr->f_GOP.f_Height, handoverHdrPtr->f_GOP.f_Width, 0, 0);
+ ToolboxDrawZone(RGB(FF, FF, FF), handoverHdrPtr->f_GOP.f_Height,
+ handoverHdrPtr->f_GOP.f_Width, 0, 0);
ToolboxClearRsrc();
- ToolboxDrawRsrc(Driver, DRIVER_HEIGHT, DRIVER_WIDTH, (handoverHdrPtr->f_GOP.f_Width - DRIVER_HEIGHT) / 2, (handoverHdrPtr->f_GOP.f_Height - DRIVER_HEIGHT) / 2);
+ ToolboxDrawRsrc(Driver, DRIVER_HEIGHT, DRIVER_WIDTH,
+ (handoverHdrPtr->f_GOP.f_Width - DRIVER_HEIGHT) / 2,
+ (handoverHdrPtr->f_GOP.f_Height - DRIVER_HEIGHT) / 2);
ToolboxClearRsrc();
@@ -147,9 +150,40 @@ 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);
+
+ 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\n");
+ }
+
+ BFileReader kernelFile(L"NewKernel.exe", ImageHandle);
+ kernelFile.ReadAll(KIB(512), 4096);
+
+ ExecOptionalHeaderPtr headerKind = (ExecOptionalHeaderPtr)rt_find_exec_header((DosHeaderPtr)kernelFile.Blob());
+
+ if (!headerKind) {
+ EFI::RaiseHardError(L"Bad-Exec", L"New Boot can't recognize this executable.");
+ }
+
+ BootMainKind main = (BootMainKind)nullptr;
+
+ if (!main) {
+ EFI::RaiseHardError(L"Bad-Exec", L"New Boot can't recognize this executable.");
+ }
+
EFI::ExitBootServices(MapKey, ImageHandle);
- /// TODO: Read catalog and read NewKernel.exe
+ main(handoverHdrPtr);
EFI::Stop();
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 530abea8..197eb91b 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -20,7 +20,7 @@ endif
IMG=epm.img
IMG_2=epm-slave.img
-EMU_FLAGS=-net none -smp 4 -m 4G -M q35 -bios OVMF.fd -device piix3-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -drive file=fat:rw:CDROM,index=2,format=raw -d int -hdd epm-slave.img
+EMU_FLAGS=-net none -smp 4 -m 8G -M q35 -bios OVMF.fd -device piix3-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -drive file=fat:rw:CDROM,index=2,format=raw -d int -hdd epm-slave.img
LD_FLAGS=-e Main --subsystem=10
@@ -36,13 +36,23 @@ FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mgeneral-regs-only -mno-red-zone -D__KE
invalid-recipe:
@echo "invalid-recipe: Use make bootloader-<arch> instead."
+KERNEL_OBJ=kernel.bin
+DD=dd
+IMG_CREATE=qemu-img
+MAX_KERNEL_SIZE=1024K
+BOOT_LOADER=NewBoot.exe
+KERNEL=NewKernel.exe
+
.PHONY: all
all: compile-amd64
mkdir -p CDROM/EFI/BOOT
- $(LD_GNU) $(OBJ) $(LD_FLAGS) -o NewBoot.exe
- $(COPY) NewBoot.exe CDROM/EFI/BOOT/BOOTX64.EFI
- $(COPY) NewBoot.exe CDROM/EFI/BOOT/NEWBOOT.EFI
- $(COPY) NewBoot.exe ../../Root/Boot/NewBoot.exe
+ $(LD_GNU) $(OBJ) $(LD_FLAGS) -o $(KERNEL_OBJ)
+ $(IMG_CREATE) create -f raw $(BOOT_LOADER) $(MAX_KERNEL_SIZE)
+ $(DD) if=$(KERNEL_OBJ) of=$(BOOT_LOADER) bs=1 seek=0 conv=notrunc
+ $(COPY) $(BOOT_LOADER) CDROM/EFI/BOOT/BOOTX64.EFI
+ $(COPY) $(BOOT_LOADER) CDROM/EFI/BOOT/NEWBOOT.EFI
+ $(COPY) $(BOOT_LOADER) ../../Root/Boot/$(BOOT_LOADER)
+ $(COPY) ../../$(KERNEL) CDROM/$(KERNEL)
ifneq ($(DEBUG_SUPPORT), )
DEBUG = -D__DEBUG__
diff --git a/Private/Source/AppMain.cxx b/Private/Source/AppMain.cxx
index ba5d822f..87705393 100644
--- a/Private/Source/AppMain.cxx
+++ b/Private/Source/AppMain.cxx
@@ -5,7 +5,6 @@
------------------------------------------- */
#include <ArchKit/ArchKit.hpp>
-#include <Builtins/Toolbox/Rsrc/Splash.rsrc>
#include <Builtins/Toolbox/Toolbox.hxx>
#include <FirmwareKit/Handover.hxx>
#include <KernelKit/FileManager.hpp>
diff --git a/Private/makefile b/Private/makefile
index 4d871c82..128ccc55 100644
--- a/Private/makefile
+++ b/Private/makefile
@@ -56,9 +56,16 @@ newos-amd64-epm: clean
OBJCOPY=x86_64-w64-mingw32-objcopy
+KERNEL_OBJ=kernel.bin
+DD=dd
+IMG_CREATE=qemu-img
+MAX_KERNEL_SIZE=1024K
+
.PHONY: link-amd64-epm
link-amd64-epm:
- $(LD) $(LDFLAGS) $(LDOBJ) -o $(KERNEL)
+ $(LD) $(LDFLAGS) $(LDOBJ) -o $(KERNEL_OBJ)
+ $(IMG_CREATE) create -f raw $(KERNEL) $(MAX_KERNEL_SIZE)
+ $(DD) if=$(KERNEL_OBJ) of=$(KERNEL) bs=1 seek=0 conv=notrunc
$(COPY) $(KERNEL) Root/Boot
.PHONY: all