diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-04 16:29:09 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-04 16:29:09 +0200 |
| commit | 1b92501a27f8781945bc6b19bb43e22588d4c933 (patch) | |
| tree | 8e73c4045188b0620bd8612dacdbab449ae97f94 /Kernel | |
| parent | a38083f7d528111087949a0ba8e3970f091f2fc9 (diff) | |
[IMP] ProgramLoader class for PE32+.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel')
| -rw-r--r-- | Kernel/HALKit/AMD64/HalBoot.asm | 3 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx | 4 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/HalKernelMain.cxx | 73 | ||||
| -rw-r--r-- | Kernel/KernelKit/PE.hxx | 12 | ||||
| -rw-r--r-- | Kernel/amd64-efi.make | 4 |
5 files changed, 56 insertions, 40 deletions
diff --git a/Kernel/HALKit/AMD64/HalBoot.asm b/Kernel/HALKit/AMD64/HalBoot.asm index f03982e6..6cd119ac 100644 --- a/Kernel/HALKit/AMD64/HalBoot.asm +++ b/Kernel/HALKit/AMD64/HalBoot.asm @@ -29,4 +29,7 @@ section .text [global ke_startup_platform] ke_startup_platform: + push rax + jmp hal_init_platform + pop rax ret
\ No newline at end of file diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx index c9552851..dd912d2b 100644 --- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx +++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx @@ -12,6 +12,10 @@ #include <KernelKit/ProcessScheduler.hxx> #include <KernelKit/Timer.hxx> +// Needed for SMP. // + +#include <KernelKit/MP.hxx> + #define kAPIC_ICR_Low 0x300 #define kAPIC_ICR_High 0x310 #define kAPIC_SIPI_Vector 0x00500 diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx index 2eae6053..0ed63569 100644 --- a/Kernel/HALKit/AMD64/HalKernelMain.cxx +++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx @@ -19,6 +19,7 @@ #include <Modules/ACPI/ACPIFactoryInterface.hxx> #include <NetworkKit/IPC.hxx> #include <CFKit/Property.hxx> +#include <Modules/CoreCG/TextRenderer.hxx> #define mInitKernel(X) \ X; \ @@ -52,6 +53,8 @@ struct PROCESS_EXIT_INFO final Kernel::Char fReason[cReasonLen]; }; +STATIC Kernel::UInt32 kTextOffsetY = 30; + namespace Kernel::HAL { /// @brief Gets the system cores using the MADT. @@ -82,6 +85,11 @@ EXTERN_C void hal_init_platform( return; } + cg_write_text("NEWOSKRNL (C) ZKA TECHNOLOGIES.", kTextOffsetY, 10, RGB(0x00, 0x00, 0x00)); + kTextOffsetY += 10; + + cg_write_text("SMP OS (MAX 8 CORES).", kTextOffsetY, 10, RGB(0x00, 0x00, 0x00)); + kKernelVirtualSize = HandoverHeader->f_VirtualSize; kKernelVirtualStart = reinterpret_cast<Kernel::VoidPtr>( reinterpret_cast<Kernel::UIntPtr>(HandoverHeader->f_VirtualStart) + cHeapStartOffset); @@ -109,29 +117,30 @@ EXTERN_C void hal_init_platform( // Register the basic SCI functions. - constexpr auto cSerialAlertInterrupt = 0x10; - constexpr auto cTlsInterrupt = 0x11; - constexpr auto cTlsInstallInterrupt = 0x12; - constexpr auto cNewInterrupt = 0x13; - constexpr auto cDeleteInterrupt = 0x14; - constexpr auto cExitInterrupt = 0x15; - constexpr auto cLastExitInterrupt = 0x16; - constexpr auto cCatalogOpen = 0x17; - constexpr auto cForkRead = 0x18; - constexpr auto cForkWrite = 0x19; - constexpr auto cCatalogClose = 0x20; - constexpr auto cCatalogRemove = 0x21; - constexpr auto cCatalogCreate = 0x22; - constexpr auto cRebootInterrupt = 0x23; - constexpr auto cShutdownInterrupt = 0x24; - constexpr auto cLPCSendMsg = 0x25; - constexpr auto cLPCOpenMsg = 0x26; - constexpr auto cLPCCloseMsg = 0x27; - constexpr auto cLPCSanitizeMsg = 0x28; - - kSyscalls[cSerialAlertInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void { + constexpr auto cVGAWrite = 0x10; + constexpr auto cTlsInterrupt = 0x11; + constexpr auto cTlsInstallInterrupt = 0x12; + constexpr auto cNewInterrupt = 0x13; + constexpr auto cDeleteInterrupt = 0x14; + constexpr auto cExitInterrupt = 0x15; + constexpr auto cLastExitInterrupt = 0x16; + constexpr auto cCatalogOpen = 0x17; + constexpr auto cForkRead = 0x18; + constexpr auto cForkWrite = 0x19; + constexpr auto cCatalogClose = 0x20; + constexpr auto cCatalogRemove = 0x21; + constexpr auto cCatalogCreate = 0x22; + constexpr auto cRebootInterrupt = 0x23; + constexpr auto cShutdownInterrupt = 0x24; + constexpr auto cLPCSendMsg = 0x25; + constexpr auto cLPCOpenMsg = 0x26; + constexpr auto cLPCCloseMsg = 0x27; + constexpr auto cLPCSanitizeMsg = 0x28; + + kSyscalls[cVGAWrite].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void { const char* msg = (const char*)rdx; - Kernel::kcout << "Kernel: " << msg << "\r"; + cg_write_text(msg, kTextOffsetY, 10, RGB(0x00, 0x00, 0x00)); + kTextOffsetY += 10; }; kSyscalls[cTlsInterrupt].Leak().Leak()->fProc = [](Kernel::VoidPtr rdx) -> void { @@ -206,16 +215,16 @@ EXTERN_C void hal_init_platform( pow.Shutdown(); }; - kSyscalls[cSerialAlertInterrupt].Leak().Leak()->fHooked = true; - kSyscalls[cTlsInterrupt].Leak().Leak()->fHooked = true; - kSyscalls[cTlsInstallInterrupt].Leak().Leak()->fHooked = true; - kSyscalls[cDeleteInterrupt].Leak().Leak()->fHooked = true; - kSyscalls[cNewInterrupt].Leak().Leak()->fHooked = true; - kSyscalls[cExitInterrupt].Leak().Leak()->fHooked = true; - kSyscalls[cLastExitInterrupt].Leak().Leak()->fHooked = true; - kSyscalls[cShutdownInterrupt].Leak().Leak()->fHooked = true; - kSyscalls[cRebootInterrupt].Leak().Leak()->fHooked = true; - kSyscalls[cLPCSanitizeMsg].Leak().Leak()->fHooked = true; + kSyscalls[cVGAWrite].Leak().Leak()->fHooked = true; + kSyscalls[cTlsInterrupt].Leak().Leak()->fHooked = true; + kSyscalls[cTlsInstallInterrupt].Leak().Leak()->fHooked = true; + kSyscalls[cDeleteInterrupt].Leak().Leak()->fHooked = true; + kSyscalls[cNewInterrupt].Leak().Leak()->fHooked = true; + kSyscalls[cExitInterrupt].Leak().Leak()->fHooked = true; + kSyscalls[cLastExitInterrupt].Leak().Leak()->fHooked = true; + kSyscalls[cShutdownInterrupt].Leak().Leak()->fHooked = true; + kSyscalls[cRebootInterrupt].Leak().Leak()->fHooked = true; + kSyscalls[cLPCSanitizeMsg].Leak().Leak()->fHooked = true; // newoskrnl version 1.00. Kernel::StringView strVer(cMaxPropLen); diff --git a/Kernel/KernelKit/PE.hxx b/Kernel/KernelKit/PE.hxx index bcf325c6..2931410f 100644 --- a/Kernel/KernelKit/PE.hxx +++ b/Kernel/KernelKit/PE.hxx @@ -26,6 +26,7 @@ typedef struct ExecHeader final { + Kernel::UInt32 mSignature; Kernel::UInt16 mMachine; Kernel::UInt16 mNumberOfSections; Kernel::UInt32 mTimeDateStamp; @@ -33,7 +34,7 @@ typedef struct ExecHeader final Kernel::UInt32 mNumberOfSymbols; Kernel::UInt16 mSizeOfOptionalHeader; Kernel::UInt16 mCharacteristics; -} PACKED ExecHeader, *ExecHeaderPtr; +} ExecHeader, *ExecHeaderPtr; typedef struct ExecOptionalHeader final { @@ -67,7 +68,7 @@ typedef struct ExecOptionalHeader final Kernel::UInt32 mSizeOfHeapCommit; Kernel::UInt32 mLoaderFlags; Kernel::UInt32 mNumberOfRvaAndSizes; -} PACKED ExecOptionalHeader, *ExecOptionalHeaderPtr; +} ExecOptionalHeader, *ExecOptionalHeaderPtr; typedef struct ExecSectionHeader final { @@ -81,7 +82,7 @@ typedef struct ExecSectionHeader final Kernel::UInt16 mNumberOfRelocations; Kernel::UInt16 mNumberOfLinenumbers; Kernel::UInt32 mCharacteristics; -} ExecSectionHeader, *ExecSectionHeaderPtr; +} ExecSectionHeader, *ExecSectionHeaderPtr; enum kExecDataDirParams { @@ -104,7 +105,7 @@ typedef struct ExecExportDirectory Kernel::UInt32 mAddressOfFunctions; // export table rva Kernel::UInt32 mAddressOfNames; Kernel::UInt32 mAddressOfNameOrdinal; // ordinal table rva -} PACKED ExecExportDirectory, *ExecExportDirectoryPtr; +} ExecExportDirectory, *ExecExportDirectoryPtr; typedef struct ExecImportDirectory { @@ -116,7 +117,7 @@ typedef struct ExecImportDirectory Kernel::UInt32 mForwarderChain; Kernel::UInt32 mNameRva; Kernel::UInt32 mThunkTableRva; -} PACKED ExecImportDirectory, *ExecImportDirectoryPtr; +} ExecImportDirectory, *ExecImportDirectoryPtr; typedef struct ExecDataDirectory { Kernel::UInt32 VirtualAddress; @@ -124,7 +125,6 @@ typedef struct ExecDataDirectory { } ExecDataDirectory, *ExecDataDirectoryPtr; typedef struct ExecImageHeader { - Kernel::UInt32 mSignature; ExecHeader mHeader; ExecOptionalHeader mOptHdr; } ExecImageHeader, *ExecImageHeaderPtr; diff --git a/Kernel/amd64-efi.make b/Kernel/amd64-efi.make index fd2ecc55..bf41827b 100644 --- a/Kernel/amd64-efi.make +++ b/Kernel/amd64-efi.make @@ -5,7 +5,7 @@ CC = x86_64-w64-mingw32-g++ LD = x86_64-w64-mingw32-ld -CCFLAGS = -fshort-wchar -c -ffreestanding -fPIC -D__NEWOS_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions \ +CCFLAGS = -fshort-wchar -c -ffreestanding -fPIC -shared -D__NEWOS_AMD64__ -mno-red-zone -fno-rtti -fno-exceptions \ -std=c++20 -D__NEWOS_SUPPORT_NX__ -I../Vendor -D__FSKIT_USE_NEWFS__ \ -D__NEWOSKRNL__ -D__HAVE_MAHROUSS_APIS__ -D__MAHROUSS__ -I./ -I../ @@ -35,7 +35,7 @@ COPY = cp ASMFLAGS = -f win64 # Kernel subsystem is 17 and entrypoint is __ImageStart -LDFLAGS = -e ke_startup_platform --subsystem=17 +LDFLAGS = -e ke_startup_platform --subsystem=17 --image-base 0x10000000 LDOBJ = Objects/*.obj # This file is the kernel, responsible of task management and memory. |
