summaryrefslogtreecommitdiffhomepage
path: root/Kernel
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-06-19 10:37:44 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-06-19 10:38:04 +0200
commit720e24cea004356da037648b92fd7eb02f3c74a8 (patch)
tree462800937d7563b8bea12a0716f4ad007982e881 /Kernel
parentb820eb6a5a7948597d81998137b05ddc0eb0dbad (diff)
kernel: add newstd.hxx and new syscalls.
includes: - Exit program with code. - Last exit code. acpi: fix invalid C cast. Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/ArchKit/ArchKit.hpp2
-rw-r--r--Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx7
-rw-r--r--Kernel/HALKit/AMD64/HalKernelMain.cxx68
-rw-r--r--Kernel/HALKit/AMD64/Storage/ATA-DMA.cxx4
-rw-r--r--Kernel/NewKit/Defines.hpp2
5 files changed, 59 insertions, 24 deletions
diff --git a/Kernel/ArchKit/ArchKit.hpp b/Kernel/ArchKit/ArchKit.hpp
index c889c93c..ba2a1903 100644
--- a/Kernel/ArchKit/ArchKit.hpp
+++ b/Kernel/ArchKit/ArchKit.hpp
@@ -17,7 +17,7 @@
#elif defined(__NEWOS_PPC__)
#include <HALKit/POWER/Processor.hpp>
#else
-#error Unknown architecture
+#error !!! unknown architecture !!!
#endif
namespace NewOS
diff --git a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
index c9b1cb1f..213be057 100644
--- a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
+++ b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
@@ -77,10 +77,13 @@ namespace NewOS
if (rsdPtr->Revision <= 1)
return ErrorOr<voidPtr>{-1};
- RSDT* xsdt = (RSDT*)(rsdPtr->RsdtAddress);
+ RSDT* xsdt = reinterpret_cast<RSDT*>(rsdPtr->RsdtAddress);
Int64 num = (xsdt->Length - sizeof(SDT)) / sizeof(UInt32);
+ /***
+ crucial to avoid - overflows.
+ */
if (num < 1)
{
/// stop here, we should have entries...
@@ -99,7 +102,7 @@ namespace NewOS
for (Size index = 0; index < this->fEntries; ++index)
{
- SDT& sdt = *(SDT*)xsdt->AddressArr[index];
+ SDT& sdt = *reinterpret_cast<SDT*>(xsdt->AddressArr[index]);
kcout << "ACPI: Revision: " << number(sdt.CreatorID) << endl;
diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx
index 8c4a05dc..8efe94b7 100644
--- a/Kernel/HALKit/AMD64/HalKernelMain.cxx
+++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx
@@ -21,6 +21,26 @@ EXTERN_C void KeMain();
EXTERN_C NewOS::VoidPtr kInterruptVectorTable[];
+struct PACKED HeapAllocInfo final
+{
+ NewOS::VoidPtr fThe;
+ NewOS::Size fTheSz;
+};
+
+struct PACKED ProcessBlockInfo final
+{
+ ThreadInformationBlock* fTIB;
+ ThreadInformationBlock* fPIB;
+};
+
+struct PACKED ProcessExitInfo final
+{
+ STATIC constexpr auto cReasonLen = 512;
+
+ NewOS::Int64 fCode;
+ NewOS::Char fReason[cReasonLen];
+};
+
namespace NewOS::HAL
{
/// @brief Gets the system cores using the MADT.
@@ -74,14 +94,24 @@ EXTERN_C void hal_init_platform(
NewOS::HAL::IDTLoader idt;
idt.Load(idtBase);
- /* install basic syscalls. */
-
+ /**
+ register basic syscalls.
+ */
+
constexpr auto cSerialWriteInterrupt = 0x10; // 16
constexpr auto cTlsInterrupt = 0x11; // 17
constexpr auto cTlsInstallInterrupt = 0x12; // 18
constexpr auto cNewInterrupt = 0x13; // 19
constexpr auto cDeleteInterrupt = 0x14; // 20
-
+ 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;
+
kSyscalls[cSerialWriteInterrupt].Leak().Leak()->fProc = [](NewOS::VoidPtr rdx) -> void {
const char* msg = (const char*)rdx;
NewOS::kcout << "newoskrnl: " << msg << "\r";
@@ -91,20 +121,7 @@ EXTERN_C void hal_init_platform(
tls_check_syscall_impl(rdx);
};
- struct PACKED HeapAllocInfo final
- {
- NewOS::VoidPtr fThe;
- NewOS::Size fTheSz;
- };
-
- struct PACKED ProcessBlockInfo final
- {
- ThreadInformationBlock* fTIB;
- ThreadInformationBlock* fPIB;
- };
-
kSyscalls[cNewInterrupt].Leak().Leak()->fProc = [](NewOS::VoidPtr rdx)->void {
-
/// get HAC struct.
HeapAllocInfo* rdxInf = reinterpret_cast<HeapAllocInfo*>(rdx);
@@ -126,17 +143,32 @@ EXTERN_C void hal_init_platform(
/// install the process's fTIB and fPIB.
rt_install_tib(rdxPb->fTIB, rdxPb->fPIB);
};
+
+ kSyscalls[cExitInterrupt].Leak().Leak()->fProc = [](NewOS::VoidPtr rdx)->void {
+ ProcessExitInfo* rdxEi = reinterpret_cast<ProcessExitInfo*>(rdx);
+
+ NewOS::kcout << "newoskrnl: " << rdxEi->fReason << "\r";
+ NewOS::ProcessScheduler::The().Leak().TheCurrent().Leak().Exit(rdxEi->fCode);
+ };
+
+ kSyscalls[cLastExitInterrupt].Leak().Leak()->fProc = [](NewOS::VoidPtr rdx)->void {
+ ProcessExitInfo* rdxEi = reinterpret_cast<ProcessExitInfo*>(rdx);
+ rdxEi->fCode = NewOS::rt_get_exit_code();
+ };
kSyscalls[cSerialWriteInterrupt].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;
NewOS::HAL::Detail::_ke_power_on_self_test();
- /* Call generic kernel entrypoint. */
-
+ /**
+ call kernel entrypoint.
+ */
KeMain();
NewOS::ke_stop(RUNTIME_CHECK_BOOTSTRAP);
diff --git a/Kernel/HALKit/AMD64/Storage/ATA-DMA.cxx b/Kernel/HALKit/AMD64/Storage/ATA-DMA.cxx
index fea103dd..4e41e3ce 100644
--- a/Kernel/HALKit/AMD64/Storage/ATA-DMA.cxx
+++ b/Kernel/HALKit/AMD64/Storage/ATA-DMA.cxx
@@ -28,11 +28,11 @@ STATIC PRDT kPRDT;
#ifdef __ATA_DMA__
#ifdef __ATA_PIO__
-#error You cant have both PIO and DMA enabled!
+#error !!! You cant have both PIO and DMA enabled! !!!
#endif /* ifdef __ATA_PIO__ */
#ifdef __AHCI__
-#error You cant have both ATA and AHCI enabled!
+#error !!! You cant have both ATA and AHCI enabled! !!!
#endif /* ifdef __AHCI__ */
#endif /* ifdef __ATA_DMA__ */
diff --git a/Kernel/NewKit/Defines.hpp b/Kernel/NewKit/Defines.hpp
index 3210f1ef..00fb5df9 100644
--- a/Kernel/NewKit/Defines.hpp
+++ b/Kernel/NewKit/Defines.hpp
@@ -17,7 +17,7 @@
#ifdef __has_feature
#if !__has_feature(cxx_nullptr)
#if !__has_nullptr
-#error You must at least have nullptr featured on your C++ compiler.
+#error !!! You must at least have nullptr featured on your C++ compiler. !!!
#endif
#endif
#endif