summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-28 22:29:45 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-28 22:29:45 +0100
commit4a21ce8c1d7e7f2e080d2c348c1ba01558062611 (patch)
treec860dfe6f69a2abd4e575b36cce88212f1b1ef2a
parentdbe7795edd9c814a5c993941c961f6b26e249e43 (diff)
Kernel: Got NewBoot to boot on EFI.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
-rw-r--r--Private/NewBoot/Source/CDROM/.gitkeep0
-rw-r--r--Private/NewBoot/Source/CDROM/EFI/BOOT/.gitkeep0
-rw-r--r--Private/NewBoot/Source/CDROM/EFI/STARTUP.NSH2
-rw-r--r--Private/NewBoot/Source/CDROM/MAHROUSS/.gitkeep0
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx (renamed from Private/NewBoot/Source/HEL/AMD64/EFIApiCrt0.cxx)3
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/PartitionMap.hxx82
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/Protocol.hxx (renamed from Private/NewBoot/Source/HEL/AMD64/EFIApi.hxx)13
-rw-r--r--Private/NewBoot/Source/makefile6
8 files changed, 20 insertions, 86 deletions
diff --git a/Private/NewBoot/Source/CDROM/.gitkeep b/Private/NewBoot/Source/CDROM/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Private/NewBoot/Source/CDROM/.gitkeep
diff --git a/Private/NewBoot/Source/CDROM/EFI/BOOT/.gitkeep b/Private/NewBoot/Source/CDROM/EFI/BOOT/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Private/NewBoot/Source/CDROM/EFI/BOOT/.gitkeep
diff --git a/Private/NewBoot/Source/CDROM/EFI/STARTUP.NSH b/Private/NewBoot/Source/CDROM/EFI/STARTUP.NSH
new file mode 100644
index 00000000..d29ba8fd
--- /dev/null
+++ b/Private/NewBoot/Source/CDROM/EFI/STARTUP.NSH
@@ -0,0 +1,2 @@
+fs0:
+BOOT\BOOTX64.EFI
diff --git a/Private/NewBoot/Source/CDROM/MAHROUSS/.gitkeep b/Private/NewBoot/Source/CDROM/MAHROUSS/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Private/NewBoot/Source/CDROM/MAHROUSS/.gitkeep
diff --git a/Private/NewBoot/Source/HEL/AMD64/EFIApiCrt0.cxx b/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx
index 2044c3fd..d8a26acd 100644
--- a/Private/NewBoot/Source/HEL/AMD64/EFIApiCrt0.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/EfiMain.cxx
@@ -7,10 +7,11 @@
* ========================================================
*/
-#include "EFIApi.hxx"
+#include "Protocol.hxx"
extern "C" int EfiMain(void *ImageHandle, EfiSystemTable *SystemTable)
{
SystemTable->conOut->output_string(SystemTable->conOut, L"HCORELDR: Preparing Handover structure...\r\n");
+
return 0;
}
diff --git a/Private/NewBoot/Source/HEL/AMD64/PartitionMap.hxx b/Private/NewBoot/Source/HEL/AMD64/PartitionMap.hxx
index 9dcd967f..490cc41a 100644
--- a/Private/NewBoot/Source/HEL/AMD64/PartitionMap.hxx
+++ b/Private/NewBoot/Source/HEL/AMD64/PartitionMap.hxx
@@ -7,84 +7,4 @@
* ========================================================
*/
-#ifndef __PARTITION_MAP__
-#define __PARTITION_MAP__
-
-#define UUID_LEN 37
-
-/* the first 512 > x > 1024 bytes of a disk contains this headers. */
-
-/**
- * @brief The EPM bootloader block.
- * boot code info
- */
-struct __attribute__((packed)) BootBlock
-{
- char magic[4];
- char name[32];
- char uuid[UUID_LEN];
- int version;
- long long int num_blocks;
- long long int sector_sz;
- long long int sector_start;
-};
-
-/**
- * @brief The EPM partition block.
- * used to explain a partition inside a media.
- */
-struct __attribute__((packed)) PartitionBlock
-{
- char name[32];
- int magic;
- long long int sector_end;
- long long int sector_sz;
- long long int sector_start;
- short type;
- int version;
- char fs[16]; /* ffs_2 */
-};
-
-/* @brief AMD64 magic for EPM */
-#define PM_MAGIC_X86 "EPMAM"
-
-/* @brief RISC-V magic for EPM */
-#define PM_MAGIC_RV "EPMRV"
-
-/* @brief ARM magic for EPM */
-#define PM_MAGIC_ARM "EPMAR"
-
-/* @brief 64x0 magic for EPM */
-#define PM_MAGIC_64x0 "EPM64"
-
-/* @brief 32x0 magic for EPM */
-#define PM_MAGIC_32x0 "EPM32"
-
-#define PM_MAX_BLKS 128
-
-#define PM_BOOT_BLK_SZ sizeof(struct boot_block)
-#define PM_PART_BLK_SZ sizeof(struct part_block)
-
-//! version types.
-//! use in boot block version field.
-
-enum
-{
- EPM_MPUNIX = 0xcf,
- EPM_LINUX = 0x8f,
- EPM_BSD = 0x9f,
- EPM_HCORE = 0x1f,
-};
-
-/// END SPECS
-
-typedef struct BootBlock BootBlockType;
-typedef struct PartitionBlock PartitionBlockType;
-
-#ifdef __x86_64__
-#define PM_MAG PM_MAGIC_X86
-#else
-#define PM_MAG "?"
-#endif
-
-#endif // ifndef __PARTITION_MAP__
+#include <HALKit/EPM.hxx>
diff --git a/Private/NewBoot/Source/HEL/AMD64/EFIApi.hxx b/Private/NewBoot/Source/HEL/AMD64/Protocol.hxx
index 4868fa00..7e292c7d 100644
--- a/Private/NewBoot/Source/HEL/AMD64/EFIApi.hxx
+++ b/Private/NewBoot/Source/HEL/AMD64/Protocol.hxx
@@ -13,11 +13,18 @@
namespace HEL
{
+using namespace hCore;
+
struct HandoverHeader final
{
- int magic;
- int type;
- int arch;
+ Int32 magic;
+ Int32 type;
+ Int32 arch;
// WIP
};
} // namespace HEL
+
+#define kHandoverMagic 0xBAD55
+
+#define kBaseHandoverStruct 0x10000000
+#define kHandoverStructSz sizeof(HEL::HandoverHeader)
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index e0ee861d..c5c382ac 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -10,8 +10,12 @@ FLAG_GNU=-fshort-wchar -fPIC -D__DBG__ -DEFI_FUNCTION_WRAPPER -I../ -I../../ -I.
.PHONY: arch-amd64
arch-amd64:
$(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx
- $(LD_GNU) *.o -filealign:16 --subsystem=10 -ffreestanding -shared -o HCORELDR.EXE
+ $(LD_GNU) *.o -e efi_main -filealign:16 -shared --subsystem=10 -ffreestanding -o HCORELDR.EXE
+ cp HCORELDR.EXE CDROM/EFI/BOOT/BOOTX64.EFI
+.PHONY: efi-debug
+efi-debug:
+ qemu-system-x86_64 -bios OVMF.fd -net none -drive file=fat:rw:CDROM,format=raw -d int
.PHONY: clean
clean: