summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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
-rw-r--r--Public/Developer/SystemLib/Headers/Dialog.h4
-rw-r--r--Public/Developer/SystemLib/Headers/Wm.h59
12 files changed, 120 insertions, 52 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
diff --git a/Public/Developer/SystemLib/Headers/Dialog.h b/Public/Developer/SystemLib/Headers/Dialog.h
index 800f56db..823b3366 100644
--- a/Public/Developer/SystemLib/Headers/Dialog.h
+++ b/Public/Developer/SystemLib/Headers/Dialog.h
@@ -27,13 +27,13 @@ typedef struct _DialogPort {
DialogPoint dlgPosition;
WmDialogFn dlgProc;
struct _WmGFX* dlgGfx;
- struct _WindowPort* parentPort;
+ struct _WmWindowPort* parentPort;
} DialogPort;
/// @brief Creates a new dialog from a rsrc fork id.
/// @param rsrcId the resource id.
/// @return the dialog port.
-CA_EXTERN_C DialogPort* DlgCreateFromRsrc(QWordType rsrcId);
+CA_EXTERN_C DialogPort* DlgCreateFromRsrc(QWordType rsrcId);
/// @brief Shows an message box according to format.
/// @param title the message box title
diff --git a/Public/Developer/SystemLib/Headers/Wm.h b/Public/Developer/SystemLib/Headers/Wm.h
index 66ed96a3..f6484c29 100644
--- a/Public/Developer/SystemLib/Headers/Wm.h
+++ b/Public/Developer/SystemLib/Headers/Wm.h
@@ -7,21 +7,22 @@
#pragma once
#include <Headers/Defines.h>
+#include "Headers/Dialog.h"
/*************************************************************
- *
- * File: Wm.h
+ *
+ * File: Wm.h
* Purpose: Window Manager API for NewOS.
* Date: 3/26/24
- *
+ *
* Copyright Mahrouss Logic, all rights reserved.
- *
+ *
*************************************************************/
struct _WmPoint;
-struct _WindowPort;
-
-struct _ControlPort;
+struct _WmWindowPort;
+struct _WmGFX;
+struct _WmControlPort;
struct _WmPoint;
/// @brief Window Graphics type.
@@ -33,7 +34,7 @@ typedef struct _WmGFX {
} WmGFX, *WmGFXRef;
/// @brief Window procedure type.
-typedef VoidType(*WmWindowFn)(struct _WindowPort* port, UInt32Type msg, UIntPtrType pParam, UIntPtrType iParam);
+typedef VoidType(*WmWindowFn)(struct _WmWindowPort* port, UInt32Type msg, UIntPtrType pParam, UIntPtrType iParam);
/// @brief A point, can represent the size, position of a window.
typedef struct _WmPoint {
@@ -42,7 +43,7 @@ typedef struct _WmPoint {
/// @brief Window port type, can be used to control the window.
-typedef struct _WindowPort {
+typedef struct _WmWindowPort {
WordType windowPort;
WordType windowKind;
BooleanType windowVisible : 1;
@@ -56,12 +57,12 @@ typedef struct _WindowPort {
WmPoint windowSize;
WmGFXRef windowGfx;
WmWindowFn windowProc;
- struct _WindowPort* windowMenuPort; ///! Attached menu to it.
- struct _WindowPort* windowParentPort;
+ struct _WmWindowPort* windowMenuPort; ///! Attached menu to it.
+ struct _WmWindowPort* windowParentPort;
} WindowPort;
/// @brief Control port type.
-typedef struct _ControlPort {
+typedef struct _WmControlPort {
WordType controlPort;
WordType controlKind;
BooleanType controlVisible : 1;
@@ -70,7 +71,7 @@ typedef struct _ControlPort {
WmWindowFn controlProc;
WmGFXRef controlGfx;
WindowPort* parentPort;
-} ControlPort;
+} WmControlPort;
enum {
kWmErrIncompatible = 0x74,
@@ -111,31 +112,31 @@ CA_EXTERN_C const ColorRef kRgbWhite;
/// @brief Creates a new control
/// @param id the control rsrc fork.
-/// @return
-CA_EXTERN_C ControlPort* WmCreateControl(DWordType id);
+/// @return
+CA_EXTERN_C WmControlPort* WmCreateControl(DWordType id);
/// @brief Releases the control
/// @param ctrlPort the control ref.
-/// @return
-CA_EXTERN_C VoidType WmReleaseControl(ControlPort* ctrlPort);
+/// @return
+CA_EXTERN_C VoidType WmReleaseControl(WmControlPort* ctrlPort);
-/// @brief Moves a control inside a ControlPort.
+/// @brief Moves a control inside a WmControlPort.
/// @param ctrlPort the control ref.
/// @param where where to move at.
-/// @return
-CA_EXTERN_C Int32Type WmSetControlPosition(ControlPort* ctrlPort, WmPoint where);
+/// @return
+CA_EXTERN_C Int32Type WmSetControlPosition(WmControlPort* ctrlPort, WmPoint where);
/// @brief Enable control.
-/// @param ctrlPort
-/// @param enabled
-/// @return
-CA_EXTERN_C Int32Type WmSetControlEnabled(ControlPort* ctrlPort, BooleanType enabled);
+/// @param ctrlPort
+/// @param enabled
+/// @return
+CA_EXTERN_C Int32Type WmSetControlEnabled(WmControlPort* ctrlPort, BooleanType enabled);
/// @brief Make control visible.
-/// @param ctrlPort
-/// @param visible
-/// @return
-CA_EXTERN_C Int32Type WmSetControlVisible(ControlPort* ctrlPort, BooleanType visible);
+/// @param ctrlPort
+/// @param visible
+/// @return
+CA_EXTERN_C Int32Type WmSetControlVisible(WmControlPort* ctrlPort, BooleanType visible);
/// @brief Creates a new window.
/// @param name the window name
@@ -172,4 +173,4 @@ CA_EXTERN_C WindowPort* WmGetOSDlg(void);
/// @brief Draws a blur effect on the window.
/// @param wndPort the window port.
-CA_EXTERN_C VoidType WmBlur(WindowPort* wndPort); \ No newline at end of file
+CA_EXTERN_C VoidType WmBlur(WindowPort* wndPort);