summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot
diff options
context:
space:
mode:
Diffstat (limited to 'Private/NewBoot')
-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
5 files changed, 78 insertions, 16 deletions
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__