From 84b0e780dfd9272b177c32cc3bb99f37bb88304d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 10 May 2024 07:06:43 +0200 Subject: MHR-23: Getting SMP to work... Signed-off-by: Amlal El Mahrouss --- Boot/NetBoot/Module.cxx | 5 +- Boot/NetBoot/NetBoot.hxx | 12 +++++ Boot/Source/BootloaderRsrc.rsrc | 2 +- Boot/Source/makefile | 106 -------------------------------------- Boot/makefile | 110 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 109 deletions(-) create mode 100644 Boot/NetBoot/NetBoot.hxx delete mode 100644 Boot/Source/makefile create mode 100644 Boot/makefile (limited to 'Boot') diff --git a/Boot/NetBoot/Module.cxx b/Boot/NetBoot/Module.cxx index c296903b..57841904 100644 --- a/Boot/NetBoot/Module.cxx +++ b/Boot/NetBoot/Module.cxx @@ -8,10 +8,11 @@ */ #include +#include -EXTERN_C Int32 EfiMain(Void) +EXTERN_C Int32 ModuleMain(Void) { - /// - Find a network drive called "/OnlineBoot" + /// - Find a network drive called "/Remote/NewOSKrnl" /// - Download our image /// - Boot from it. diff --git a/Boot/NetBoot/NetBoot.hxx b/Boot/NetBoot/NetBoot.hxx new file mode 100644 index 00000000..d45f1de1 --- /dev/null +++ b/Boot/NetBoot/NetBoot.hxx @@ -0,0 +1,12 @@ +/* + * ======================================================== + * + * NetBoot + * Copyright SoftwareLabs, all rights reserved. + * + * ======================================================== + */ + +#pragma once + +#include diff --git a/Boot/Source/BootloaderRsrc.rsrc b/Boot/Source/BootloaderRsrc.rsrc index d79211e7..0282192b 100644 --- a/Boot/Source/BootloaderRsrc.rsrc +++ b/Boot/Source/BootloaderRsrc.rsrc @@ -15,7 +15,7 @@ BEGIN VALUE "FileVersion", BOOTLOADER_VERSION VALUE "InternalName", "NewBoot" VALUE "LegalCopyright", "Copyright SoftwareLabs, all rights reserved." - VALUE "OriginalFilename", "NewBoot.exe" + VALUE "OriginalFilename", "NewOSLdr.exe" VALUE "ProductName", "NewBoot" VALUE "ProductVersion", BOOTLOADER_VERSION END diff --git a/Boot/Source/makefile b/Boot/Source/makefile deleted file mode 100644 index 70fa7232..00000000 --- a/Boot/Source/makefile +++ /dev/null @@ -1,106 +0,0 @@ -################################################## -# (C) SoftwareLabs, all rights reserved. -# This is the bootloader makefile. -################################################## - -CC_GNU=x86_64-w64-mingw32-g++ -LD_GNU=x86_64-w64-mingw32-ld - -WINDRES=x86_64-w64-mingw32-windres - -ADD_FILE=touch -COPY=cp -HTTP_GET=wget - -ifeq ($(shell uname), Windows_NT) -EMU=qemu-system-x86_64w -else -EMU=qemu-system-x86_64 -endif - -ifeq ($(NEWS_MODEL), ) -NEWOS_MODEL=-DkMachineModel="\"Generic NeWS HD\"" -endif - -IMG=epm.img -IMG_2=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:Root,index=2,format=raw -d int -hdd epm-slave.img - -LD_FLAGS=-e Main --subsystem=10 - -ifeq ($(NEWS_STANDLONE), ) -OBJ=*.o ../../Kernel/Objects/*.obj -else -RESCMD=$(WINDRES) BootloaderRsrc.rsrc -O coff -o BootloaderRsrc.o -STANDALONE_MACRO=-D__STANDALONE__ -OBJ=*.o -endif - -REM=rm -REM_FLAG=-f - -FLAG_ASM=-f win64 -FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mno-red-zone -D__KERNEL__ -D__NEWBOOT__ \ - -DEFI_FUNCTION_WRAPPER -I../ -I../../Kernel -I./ -c -nostdlib -fno-rtti -fno-exceptions \ - -std=c++20 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ - -BOOT_LOADER=NewBoot.exe -KERNEL=NewKernel.exe - -.PHONY: invalid-recipe -invalid-recipe: - @echo "invalid-recipe: Use make compile- instead." - -.PHONY: all -all: compile-amd64 - mkdir -p Root/EFI/BOOT - $(LD_GNU) $(OBJ) $(LD_FLAGS) -o $(BOOT_LOADER) - $(COPY) $(BOOT_LOADER) Root/EFI/BOOT/BOOTX64.EFI - $(COPY) $(BOOT_LOADER) Root/EFI/BOOT/NEWBOOT.EFI - $(COPY) ../../Kernel/$(KERNEL) Root/$(KERNEL) - -ifneq ($(DEBUG_SUPPORT), ) -DEBUG = -D__DEBUG__ -endif - -.PHONY: compile-amd64 -compile-amd64: - $(RESCMD) - $(CC_GNU) $(NEWOS_MODEL) $(STANDALONE_MACRO) $(FLAG_GNU) $(DEBUG) $(wildcard HEL/AMD64/*.cxx) $(wildcard HEL/AMD64/*.S) $(wildcard *.cxx) - -.PHONY: run-efi-amd64 -run-efi-amd64: - $(EMU) $(EMU_FLAGS) - -# img_2 is the rescue disk. img is the bootable disk, as provided by the NeWS. -.PHONY: epm-img -epm-img: - qemu-img create -f raw $(IMG) 10G - qemu-img create -f raw $(IMG_2) 512M - -.PHONY: download-edk -download-edk: - $(HTTP_GET) https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd - -BINS=*.bin -EXECUTABLES=NewBoot.exe NewKernel.exe OVMF.fd - -TARGETS=$(REM_FLAG) $(OBJ) $(BIN) $(IMG) $(IMG_2) $(EXECUTABLES) - -.PHONY: clean -clean: - $(REM) $(TARGETS) - -.PHONY: help -help: - @echo "=== HELP ===" - @echo "epm-img: Format a disk using the Explicit Partition Map." - @echo "gpt-img: Format a disk using the Explicit Partition Map." - @echo "clean: clean bootloader." - @echo "bootloader-amd64: Build bootloader. (PC AMD64)" - @echo "run-efi-amd64: Run bootloader. (PC AMD64)" diff --git a/Boot/makefile b/Boot/makefile new file mode 100644 index 00000000..878cee2a --- /dev/null +++ b/Boot/makefile @@ -0,0 +1,110 @@ +################################################## +# (C) SoftwareLabs, all rights reserved. +# This is the bootloader makefile. +################################################## + +CC_GNU=x86_64-w64-mingw32-g++ +LD_GNU=x86_64-w64-mingw32-ld + +WINDRES=x86_64-w64-mingw32-windres + +ADD_FILE=touch +COPY=cp +HTTP_GET=wget + +ifeq ($(shell uname), Windows_NT) +EMU=qemu-system-x86_64w +else +EMU=qemu-system-x86_64 +endif + +ifeq ($(NEWS_MODEL), ) +NEWOS_MODEL=-DkMachineModel="\"Generic NeWS HD\"" +endif + +BIOS=OVMF.fd +IMG=epm.img +IMG_2=epm-slave.img + +EMU_FLAGS=-net none -smp 4,sockets=1,cores=4,threads=1 -m 8G -M q35 \ + -bios Source/$(BIOS) -device piix3-ide,id=ide \ + -drive id=disk,file=Source/$(IMG),format=raw,if=none \ + -device ide-hd,drive=disk,bus=ide.0 -drive \ + file=fat:rw:Source/Root,index=2,format=raw -d int -hdd Source/$(IMG_2) + +LD_FLAGS=-e Main --subsystem=10 + +ifeq ($(NEWS_STANDLONE), ) +OBJ=*.o ../Kernel/Objects/*.obj +else +RESCMD=$(WINDRES) BootloaderRsrc.rsrc -O coff -o BootloaderRsrc.o +STANDALONE_MACRO=-D__STANDALONE__ +OBJ=*.o +endif + +REM=rm +REM_FLAG=-f + +FLAG_ASM=-f win64 +FLAG_GNU=-fshort-wchar -D__EFI_x86_64__ -mno-red-zone -D__KERNEL__ -D__NEWBOOT__ \ + -DEFI_FUNCTION_WRAPPER -I./ -I../Kernel -I./ -c -nostdlib -fno-rtti -fno-exceptions \ + -std=c++20 -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -D__BOOTLOADER__ -I./ + +BOOT_LOADER=NewOSLdr.exe +KERNEL=NewOSKrnl.exe + +.PHONY: invalid-recipe +invalid-recipe: + @echo "invalid-recipe: Use make compile- instead." + +.PHONY: all +all: compile-amd64 + mkdir -p Root/EFI/BOOT + $(LD_GNU) $(OBJ) $(LD_FLAGS) -o Source/$(BOOT_LOADER) + $(COPY) Source/$(BOOT_LOADER) Source/Root/EFI/BOOT/BOOTX64.EFI + $(COPY) Source/$(BOOT_LOADER) Source/Root/EFI/BOOT/NEWBOOT.EFI + $(COPY) ../Kernel/$(KERNEL) Source/Root/$(KERNEL) + +ifneq ($(DEBUG_SUPPORT), ) +DEBUG = -D__DEBUG__ +endif + +.PHONY: compile-amd64 +compile-amd64: + $(RESCMD) + $(CC_GNU) $(NEWOS_MODEL) $(STANDALONE_MACRO) $(FLAG_GNU) $(DEBUG) \ + $(wildcard Source/HEL/AMD64/*.cxx) \ + $(wildcard Source/HEL/AMD64/*.S) + $(wildcard Source/*.cxx) + +.PHONY: run-efi-amd64 +run-efi-amd64: + $(EMU) $(EMU_FLAGS) + +# img_2 is the rescue disk. img is the bootable disk, as provided by the NeWS. +.PHONY: epm-img +epm-img: + qemu-img create -f raw $(IMG) 10G + qemu-img create -f raw $(IMG_2) 512M + +.PHONY: download-edk +download-edk: + $(HTTP_GET) https://retrage.github.io/edk2-nightly/bin/DEBUGX64_OVMF.fd -O OVMF.fd + +BINS=*.bin +EXECUTABLES=NewOSLdr.exe NewOSKrnl.exe OVMF.fd + +TARGETS=$(REM_FLAG) $(OBJ) $(BIN) $(IMG) $(IMG_2) $(EXECUTABLES) + +.PHONY: clean +clean: + $(REM) $(TARGETS) + +.PHONY: help +help: + @echo "=== HELP ===" + @echo "epm-img: Format a disk using the Explicit Partition Map." + @echo "gpt-img: Format a disk using the Explicit Partition Map." + @echo "clean: clean bootloader." + @echo "bootloader-amd64: Build bootloader. (PC AMD64)" + @echo "run-efi-amd64: Run bootloader. (PC AMD64)" -- cgit v1.2.3