summaryrefslogtreecommitdiffhomepage
path: root/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/ArchKit/ArchKit.hpp41
-rw-r--r--Kernel/Builtins/ACPI/ACPI.hxx23
-rw-r--r--Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx29
-rw-r--r--Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp2
-rw-r--r--Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp67
-rw-r--r--Kernel/HALKit/AMD64/HalKernelMain.cxx2
-rw-r--r--Kernel/HALKit/AMD64/HalSMPCore.cxx2
-rw-r--r--Kernel/HALKit/AMD64/Processor.hpp65
-rw-r--r--Kernel/KernelKit/KernelHeap.hpp5
-rw-r--r--Kernel/KernelKit/ProcessScheduler.hxx (renamed from Kernel/KernelKit/ProcessScheduler.hpp)6
-rw-r--r--Kernel/KernelKit/ThreadLocalStorage.inl2
-rw-r--r--Kernel/Sources/AppMain.cxx26
-rw-r--r--Kernel/Sources/CodeManager.cxx2
-rw-r--r--Kernel/Sources/KernelHeap.cxx27
-rw-r--r--Kernel/Sources/PEFCodeManager.cxx2
-rw-r--r--Kernel/Sources/PEFSharedObjectRT.cxx2
-rw-r--r--Kernel/Sources/ProcessScheduler.cxx6
-rw-r--r--Kernel/Sources/ProcessTeam.cxx2
-rw-r--r--Kernel/Sources/SMPManager.cxx6
-rw-r--r--Kernel/Sources/Semaphore.cxx2
-rw-r--r--Kernel/Sources/ThreadLocalStorage.cxx2
-rw-r--r--Kernel/Sources/UserHeap.cxx2
-rw-r--r--Kernel/makefile2
23 files changed, 273 insertions, 52 deletions
diff --git a/Kernel/ArchKit/ArchKit.hpp b/Kernel/ArchKit/ArchKit.hpp
index 83770272..fa899984 100644
--- a/Kernel/ArchKit/ArchKit.hpp
+++ b/Kernel/ArchKit/ArchKit.hpp
@@ -34,6 +34,47 @@ namespace NewOS
return hash;
}
+
+ /// @brief write to mapped memory register
+ /// @param base the base address.
+ /// @param reg the register.
+ /// @param value the write to write on it.
+ inline void ke_dma_write(UInt32 base, UInt32 reg, UInt32 value) noexcept
+ {
+ *(volatile UInt32*)((UInt64)base + reg) = value;
+ }
+
+ /// @brief read from mapped memory register.
+ /// @param base base address
+ /// @param reg the register.
+ /// @return the value inside the register.
+ inline UInt32 ke_dma_read(UInt32 base, UInt32 reg) noexcept
+ {
+ return *(volatile UInt32*)((UInt64)base + reg);
+ }
+
+ /// @brief Print a region of memory.
+ /// @param start
+ /// @param length
+ inline void ke_print_raw_memory(const void* start, Size length)
+ {
+ const UInt8* ptr = (const UInt8*)start;
+ for (Size i = 0; i < length; i++)
+ {
+ if (i % 16 == 0)
+ {
+ kcout << hex_number((UIntPtr)ptr + i);
+ }
+ else
+ {
+ kcout << hex_number(ptr[i]);
+ }
+
+ kcout << " ";
+ }
+
+ kcout << "\r";
+ }
} // namespace NewOS
#define kKernelMaxSystemCalls (256)
diff --git a/Kernel/Builtins/ACPI/ACPI.hxx b/Kernel/Builtins/ACPI/ACPI.hxx
index 13ea6ecc..d9bfeaca 100644
--- a/Kernel/Builtins/ACPI/ACPI.hxx
+++ b/Kernel/Builtins/ACPI/ACPI.hxx
@@ -15,7 +15,7 @@
namespace NewOS
{
- class SDT
+ class PACKED SDT
{
public:
Char Signature[4];
@@ -29,7 +29,7 @@ namespace NewOS
UInt32 CreatorRevision;
};
- class RSDP : public SDT
+ class PACKED RSDP : public SDT
{
public:
UInt32 RsdtAddress;
@@ -38,7 +38,7 @@ namespace NewOS
UInt8 Reserved0[3];
};
- class ConfigHeader
+ class PACKED ConfigHeader
{
public:
UInt64 BaseAddress;
@@ -59,7 +59,7 @@ namespace NewOS
Invalid = 0xFF,
};
- class Address
+ class PACKED Address
{
public:
AddressSpace AddressSpaceId;
@@ -68,6 +68,21 @@ namespace NewOS
UInt8 Reserved;
UIntPtr Address;
};
+
+ class PACKED RSDT
+ {
+ public:
+ Char Signature[4];
+ UInt32 Length;
+ UInt8 Revision;
+ Char Checksum;
+ Char OemId[6];
+ Char OemTableId[8];
+ UInt32 OemRev;
+ UInt32 CreatorID;
+ UInt32 CreatorRevision;
+ UInt64 AddressArr[];
+ };
} // namespace NewOS
#endif // !__ACPI__
diff --git a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
index ff5372f4..f92554f8 100644
--- a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
+++ b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
@@ -7,6 +7,8 @@
#include <Builtins/ACPI/ACPIFactoryInterface.hxx>
#include <HALKit/AMD64/Processor.hpp>
#include <NewKit/String.hpp>
+#include <ArchKit/ArchKit.hpp>
+#include <KernelKit/KernelHeap.hpp>
namespace NewOS
{
@@ -73,28 +75,37 @@ namespace NewOS
return ErrorOr<voidPtr>{-4};
}
- SDT* xsdt = (SDT*)(rsdPtr->XsdtAddress >> (rsdPtr->XsdtAddress & 0xFFF));
+ /// FIXME
+ RSDT* xsdt = (RSDT*)rsdPtr->XsdtAddress;
- SizeT num = -(xsdt->Length - sizeof(SDT)) / 8;
+ if (NewOS::HAL::ke_map_address((PDE*)hal_read_cr3(), rsdPtr->XsdtAddress, (UIntPtr)xsdt, NewOS::HAL::eFlagsRw))
+ return ErrorOr<voidPtr>{-5};
+
+ Int64 num = (xsdt->Length - sizeof(SDT)) / sizeof(UInt64);
+
+ if (num < 1)
+ {
+ return ErrorOr<voidPtr>{-6};
+ }
this->fEntries = num;
- kcout << "ACPI: Number of entries: " << number(num) << endl;
+ kcout << "ACPI: Number of entries: " << number(this->fEntries) << endl;
kcout << "ACPI: Address of XSDT: " << hex_number((UIntPtr)xsdt) << endl;
- constexpr short ACPI_SIGNATURE_LENGTH = 4;
+ const short cAcpiSignatureLength = 4;
for (Size index = 0; index < this->fEntries; ++index)
{
- SDT& sdt = xsdt[index];
+ SDT* sdt = (SDT*)(xsdt->AddressArr[index]);
- for (short signature_index = 0; signature_index < ACPI_SIGNATURE_LENGTH; ++signature_index)
+ for (short signature_index = 0; signature_index < cAcpiSignatureLength; ++signature_index)
{
- if (sdt.Signature[signature_index] != signature[signature_index])
+ if (sdt->Signature[signature_index] != signature[signature_index])
break;
- if (signature_index == 4)
- return ErrorOr<voidPtr>(reinterpret_cast<voidPtr>(&sdt));
+ if (signature_index == (cAcpiSignatureLength - 1))
+ return ErrorOr<voidPtr>(reinterpret_cast<voidPtr>(sdt));
}
}
diff --git a/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
index 0ac7a50e..d06dc6a6 100644
--- a/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
+++ b/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
@@ -5,7 +5,7 @@
------------------------------------------- */
#include <ArchKit/ArchKit.hpp>
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
#include <NewKit/String.hpp>
/// @brief Handle GPF fault.
diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
index abd19586..287b1882 100644
--- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
+++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
@@ -7,6 +7,12 @@
#include <Builtins/ACPI/ACPIFactoryInterface.hxx>
#include <HALKit/AMD64/Processor.hpp>
#include <NewKit/KernelCheck.hpp>
+#include <ArchKit/ArchKit.hpp>
+
+#define kAPIC_ICR_Low 0x300
+#define kAPIC_ICR_High 0x310
+#define kAPIC_SIPI_Vector 0x00500
+#define kAPIC_EIPI_Vector 0x00400
///////////////////////////////////////////////////////////////////////////////////////
@@ -62,7 +68,7 @@ namespace NewOS::HAL
struct MadtProcessorLocalApic final
{
Char AcpiProcessorId;
- Char Reserved;
+ Char ApicId;
UInt32 Flags;
};
@@ -102,15 +108,66 @@ namespace NewOS::HAL
///////////////////////////////////////////////////////////////////////////////////////
- void hal_system_get_cores(voidPtr rsdPtr)
+ /// @brief Send start IPI for CPU.
+ /// @param apicId
+ /// @param vector
+ /// @param targetAddress
+ /// @return
+ Void hal_send_start_ipi(UInt32 apicId, UInt8 vector, UInt32 targetAddress)
+ {
+ NewOS::ke_dma_write(targetAddress, kAPIC_ICR_High, apicId << 24);
+ NewOS::ke_dma_write(targetAddress, kAPIC_ICR_Low, kAPIC_SIPI_Vector | vector);
+ }
+
+ /// @brief Send end IPI for CPU.
+ /// @param apicId
+ /// @param vector
+ /// @param targetAddress
+ /// @return
+ Void hal_send_end_ipi(UInt32 apicId, UInt8 vector, UInt32 targetAddress)
+ {
+ NewOS::ke_dma_write(targetAddress, kAPIC_ICR_High, apicId << 24);
+ NewOS::ke_dma_write(targetAddress, kAPIC_ICR_Low, kAPIC_EIPI_Vector | vector);
+ }
+
+ Void hal_system_get_cores(voidPtr rsdPtr)
{
auto acpi = ACPIFactoryInterface(rsdPtr);
kApicMadt = acpi.Find(kApicSignature).Leak().Leak();
- if (kApicMadt)
+ if (kApicMadt != nullptr)
{
- kcout << "New OS: APIC is present...\r";
- kApicInfoBlock = (MadtType*)kApicMadt;
+ auto madt = (SDT*)kApicMadt;
+
+ const UInt8* madt_end = (const UInt8*)madt + madt->Length;
+ const UInt8* entry_ptr = (const UInt8*)(madt + 1);
+
+ while (entry_ptr < madt_end)
+ {
+ const MadtType::MadtAddress* entry_header = (const MadtType::MadtAddress*)entry_ptr;
+
+ switch (entry_header->Flags)
+ {
+ case 0: {
+ const MadtProcessorLocalApic* local_apic = (const MadtProcessorLocalApic*)entry_ptr;
+ if (local_apic->Flags & 1)
+ {
+ // Processor is enabled
+ kcout << "Processor ID: %d, APIC ID: %d\n"
+ << number(local_apic->AcpiProcessorId) << number(local_apic->ApicId);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ entry_ptr += entry_header->RecordLen;
+ }
+
+ while (true)
+ {
+ }
}
else
{
diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx
index 07656060..3136bf76 100644
--- a/Kernel/HALKit/AMD64/HalKernelMain.cxx
+++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx
@@ -11,7 +11,7 @@
#include <KernelKit/Framebuffer.hpp>
#include <KernelKit/KernelHeap.hpp>
#include <KernelKit/PEFCodeManager.hxx>
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
#include <KernelKit/UserHeap.hpp>
#include <NewKit/Json.hpp>
diff --git a/Kernel/HALKit/AMD64/HalSMPCore.cxx b/Kernel/HALKit/AMD64/HalSMPCore.cxx
index 90703e13..7aa13068 100644
--- a/Kernel/HALKit/AMD64/HalSMPCore.cxx
+++ b/Kernel/HALKit/AMD64/HalSMPCore.cxx
@@ -4,7 +4,7 @@
------------------------------------------- */
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
using namespace NewOS;
Void ProcessHeader::SetEntrypoint(UIntPtr& imageStart) noexcept
diff --git a/Kernel/HALKit/AMD64/Processor.hpp b/Kernel/HALKit/AMD64/Processor.hpp
index 235e425d..608a502f 100644
--- a/Kernel/HALKit/AMD64/Processor.hpp
+++ b/Kernel/HALKit/AMD64/Processor.hpp
@@ -17,6 +17,7 @@
#include <NewKit/Defines.hpp>
#include <NewKit/Utils.hpp>
#include <FirmwareKit/Handover.hxx>
+#include <HALKit/AMD64/HalPageAlloc.hpp>
#ifdef kCPUBackendName
#undef kCPUBackendName
@@ -53,6 +54,68 @@ namespace NewOS
namespace NewOS::HAL
{
+
+ enum
+ {
+ eFlagsUser,
+ eFlagsRw,
+ eFlagsExecDisable
+ };
+
+ /// @brief Map address to PDE.
+ /// @param pde a valid page directory.
+ /// @param phys_addr a valid phyiscal address.
+ /// @param virt_addr a valid virtual address.
+ /// @param flags the flags to put on the page.
+ inline Int32 ke_map_address(PDE* pde, UIntPtr phys_addr, UIntPtr virt_addr, UInt32 flags)
+ {
+ UInt16 pml4_index = (virt_addr >> 39) & 0x1FF;
+
+ if (!pde->Pte[pml4_index].Present)
+ {
+ pde->Pte[pml4_index].Present = true;
+ kcout << "PM: It is present now.\r";
+ }
+ else
+ {
+ kcout << "PM: It is already present.\r";
+ kcout << "Address? " << hex_number(pde->Pte[pml4_index].PhysicalAddress) << endl;
+ kcout << "User? " << (pde->Pte[pml4_index].User ? "yes" : "no") << "\r";
+ kcout << "RW? " << (pde->Pte[pml4_index].Rw ? "yes" : "no") << "\r";
+
+ return 1;
+ }
+
+ pde->Pte[pml4_index].PhysicalAddress = phys_addr;
+ pde->Pte[pml4_index].Rw = flags & eFlagsRw;
+ pde->Pte[pml4_index].User = flags & eFlagsUser;
+ pde->Pte[pml4_index].ExecDisable = flags & eFlagsExecDisable;
+
+ return 0;
+ }
+
+ /// @brief Map address to PDE.
+ /// @param pde
+ /// @param phys_addr
+ /// @param virt_addr
+ /// @param flags
+ inline void ke_unmap_address(PDE* pde, UIntPtr phys_addr, UIntPtr virt_addr, UInt32 flags)
+ {
+ UInt16 pml4_index = (virt_addr >> 39) & 0x1FF;
+ UInt16 pdpt_index = (virt_addr >> 30) & 0x1FF;
+ UInt16 pd_index = (virt_addr >> 21) & 0x1FF;
+ UInt16 pt_index = (virt_addr >> 12) & 0x1FF;
+
+ if (pde->Pte[pml4_index].Present)
+ {
+ pde->Pte[pml4_index].Present = false;
+ pde->Pte[pml4_index].PhysicalAddress = 0;
+ pde->Pte[pml4_index].Rw = 0;
+ pde->Pte[pml4_index].User = 0;
+ pde->Pte[pml4_index].ExecDisable = 0;
+ }
+ }
+
EXTERN_C UChar In8(UInt16 port);
EXTERN_C UShort In16(UInt16 port);
EXTERN_C UInt In32(UInt16 port);
@@ -162,6 +225,8 @@ namespace NewOS::HAL
};
Void hal_system_get_cores(VoidPtr rsdPtr);
+ Void hal_send_start_ipi(UInt32 apicId, UInt8 vector, UInt32 targetAddress);
+ Void hal_send_end_ipi(UInt32 apicId, UInt8 vector, UInt32 targetAddress);
/// @brief Processor specific structures.
namespace Detail
diff --git a/Kernel/KernelKit/KernelHeap.hpp b/Kernel/KernelKit/KernelHeap.hpp
index c7b898ed..e2ab19b5 100644
--- a/Kernel/KernelKit/KernelHeap.hpp
+++ b/Kernel/KernelKit/KernelHeap.hpp
@@ -36,4 +36,9 @@ namespace NewOS
/// @param heapPtr HIB pointer.
/// @return if it valid: point has crc now., otherwise fail.
Boolean ke_protect_ke_heap(VoidPtr heapPtr);
+
+ /// @brief Makes a kernel heap page.
+ /// @param heapPtr
+ /// @return
+ Int32 ke_make_ke_page(VoidPtr heapPtr);
} // namespace NewOS
diff --git a/Kernel/KernelKit/ProcessScheduler.hpp b/Kernel/KernelKit/ProcessScheduler.hxx
index 9adaac0d..33c9f313 100644
--- a/Kernel/KernelKit/ProcessScheduler.hpp
+++ b/Kernel/KernelKit/ProcessScheduler.hxx
@@ -163,9 +163,9 @@ namespace NewOS
enum
{
- kAppKind = 3,
- kLibKind = 3,
- kDriverKind = 0,
+ kAppKind = 1,
+ kShLibKind = 2,
+ kDriverKind = 3,
kKindCount,
};
diff --git a/Kernel/KernelKit/ThreadLocalStorage.inl b/Kernel/KernelKit/ThreadLocalStorage.inl
index e2137ed6..a8269a14 100644
--- a/Kernel/KernelKit/ThreadLocalStorage.inl
+++ b/Kernel/KernelKit/ThreadLocalStorage.inl
@@ -7,7 +7,7 @@
//! @brief Allocates a pointer from the process's tls.
#ifndef __PROCESS_MANAGER__
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
#endif
template <typename T>
diff --git a/Kernel/Sources/AppMain.cxx b/Kernel/Sources/AppMain.cxx
index 692d4376..62795893 100644
--- a/Kernel/Sources/AppMain.cxx
+++ b/Kernel/Sources/AppMain.cxx
@@ -16,7 +16,7 @@
#include <KernelKit/KernelHeap.hpp>
#include <KernelKit/PEF.hpp>
#include <KernelKit/PEFCodeManager.hxx>
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
#include <KernelKit/UserHeap.hpp>
#include <NewKit/Json.hpp>
#include <NewKit/KernelCheck.hpp>
@@ -182,31 +182,31 @@ namespace NewOS::Detail
/// @brief System loader entrypoint.
/// @param void no parameters.
/// @return void no return value.
- STATIC NewOS::Void AppSystemLoader(NewOS::Void)
+ STATIC NewOS::Void AppSystem(NewOS::Void)
{
- NewOS::PEFLoader coreGraphicsShLib("/System/WindowServer");
+ NewOS::PEFLoader wndServer("/System/WindowServer");
- if (!coreGraphicsShLib.IsLoaded())
+ if (!wndServer.IsLoaded())
{
NewOS::ke_stop(RUNTIME_CHECK_FAILED);
}
- NewOS::Utils::execute_from_image(coreGraphicsShLib,
- NewOS::ProcessHeader::kLibKind);
+ NewOS::Utils::execute_from_image(wndServer,
+ NewOS::ProcessHeader::kAppKind);
- NewOS::PEFLoader logonService("/System/Login");
+ NewOS::PEFLoader launchServer("/System/Launcher");
- if (!logonService.IsLoaded())
+ if (!launchServer.IsLoaded())
{
NewOS::ke_stop(RUNTIME_CHECK_FAILED);
}
- NewOS::Utils::execute_from_image(logonService,
+ NewOS::Utils::execute_from_image(launchServer,
NewOS::ProcessHeader::kAppKind);
- NewOS::kcout << "SystemLoader: Exiting process, we're done initializing stuff...";
+ NewOS::kcout << "System: done, sleeping...";
- NewOS::ProcessScheduler::The().Leak().GetCurrent().Leak().Exit(0);
+ while (true) {}
}
} // namespace NewOS::Detail
@@ -218,8 +218,8 @@ EXTERN_C NewOS::Void AppMain(NewOS::Void)
/// Now run kernel loop, until no process are running.
NewOS::Detail::FilesystemWizard wizard; // automatic.
- auto cLoaderName = "SystemLoader";
- NewOS::execute_from_image(NewOS::Detail::AppSystemLoader, cLoaderName);
+ auto cLoaderName = "System";
+ NewOS::execute_from_image(NewOS::Detail::AppSystem, cLoaderName);
while (NewOS::ProcessScheduler::The().Leak().Run() > 0) {}
}
diff --git a/Kernel/Sources/CodeManager.cxx b/Kernel/Sources/CodeManager.cxx
index 7483b32f..10de3512 100644
--- a/Kernel/Sources/CodeManager.cxx
+++ b/Kernel/Sources/CodeManager.cxx
@@ -6,7 +6,7 @@
#include <NewKit/Utils.hpp>
#include <KernelKit/CodeManager.hpp>
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
namespace NewOS
{
diff --git a/Kernel/Sources/KernelHeap.cxx b/Kernel/Sources/KernelHeap.cxx
index a8ca467e..93f0c164 100644
--- a/Kernel/Sources/KernelHeap.cxx
+++ b/Kernel/Sources/KernelHeap.cxx
@@ -38,7 +38,10 @@ namespace NewOS
SizeT fTargetPtrSize;
/// @brief 64-bit target pointer.
UIntPtr fTargetPtr;
- UInt8 fPadding[kKernelHeapHeaderPaddingSz];
+ /// @brief Is this a page pointer?
+ Boolean fPagePtr;
+ /// @brief Padding bytes for header.
+ UInt8 fPadding[kKernelHeapHeaderPaddingSz];
};
typedef HeapInformationBlock* HeapInformationBlockPtr;
@@ -64,6 +67,7 @@ namespace NewOS
heapInfo->fMagic = kKernelHeapMagic;
heapInfo->fCRC32 = 0; // dont fill it for now.
heapInfo->fTargetPtr = wrapper.VirtualAddress();
+ heapInfo->fPagePtr = 0;
++kHeapCount;
@@ -71,6 +75,27 @@ namespace NewOS
sizeof(Detail::HeapInformationBlock));
}
+ /// @brief Makes a page heap.
+ /// @param heapPtr
+ /// @return
+ Int32 ke_make_ke_page(VoidPtr heapPtr)
+ {
+ if (kHeapCount < 1)
+ return -kErrorInternal;
+ if (((IntPtr)heapPtr - sizeof(Detail::HeapInformationBlock)) <= 0)
+ return -kErrorInternal;
+ if (((IntPtr)heapPtr - kBadPtr) < 0)
+ return -kErrorInternal;
+
+ Detail::HeapInformationBlockPtr virtualAddress =
+ reinterpret_cast<Detail::HeapInformationBlockPtr>(
+ (UIntPtr)heapPtr - sizeof(Detail::HeapInformationBlock));
+
+ virtualAddress->fPagePtr = 1;
+
+ return 0;
+ }
+
/// @brief Declare pointer as free.
/// @param heapPtr the pointer.
/// @return
diff --git a/Kernel/Sources/PEFCodeManager.cxx b/Kernel/Sources/PEFCodeManager.cxx
index c0997dff..a84730e9 100644
--- a/Kernel/Sources/PEFCodeManager.cxx
+++ b/Kernel/Sources/PEFCodeManager.cxx
@@ -8,7 +8,7 @@
#include <KernelKit/FileManager.hpp>
#include <KernelKit/KernelHeap.hpp>
#include <KernelKit/PEFCodeManager.hxx>
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
#include <NewKit/Defines.hpp>
#include <NewKit/KernelCheck.hpp>
#include <NewKit/OwnPtr.hpp>
diff --git a/Kernel/Sources/PEFSharedObjectRT.cxx b/Kernel/Sources/PEFSharedObjectRT.cxx
index 33df8857..3ddef245 100644
--- a/Kernel/Sources/PEFSharedObjectRT.cxx
+++ b/Kernel/Sources/PEFSharedObjectRT.cxx
@@ -10,7 +10,7 @@
#include <KernelKit/DebugOutput.hpp>
#include <KernelKit/PEF.hpp>
#include <KernelKit/PEFSharedObject.hxx>
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
#include <KernelKit/ThreadLocalStorage.hxx>
#include <NewKit/Defines.hpp>
diff --git a/Kernel/Sources/ProcessScheduler.cxx b/Kernel/Sources/ProcessScheduler.cxx
index 32e1fbde..bf088cc6 100644
--- a/Kernel/Sources/ProcessScheduler.cxx
+++ b/Kernel/Sources/ProcessScheduler.cxx
@@ -9,7 +9,7 @@
/// @brief MicroKernel process scheduler.
/***********************************************************************************/
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
#include <KernelKit/SMPManager.hpp>
#include <KernelKit/KernelHeap.hpp>
#include <NewKit/String.hpp>
@@ -206,7 +206,7 @@ namespace NewOS
if (!process.Leak().Image)
{
- if (process.Leak().Kind != ProcessHeader::kLibKind)
+ if (process.Leak().Kind != ProcessHeader::kShLibKind)
{
return -kErrorNoEntrypoint;
}
@@ -223,7 +223,7 @@ namespace NewOS
/// Create heap according to type of process.
if (process.Leak().Kind == ProcessHeader::kAppKind)
process.Leak().HeapPtr = rt_new_heap(kUserHeapUser | kUserHeapRw);
- else if (process.Leak().Kind == ProcessHeader::kLibKind)
+ else if (process.Leak().Kind == ProcessHeader::kShLibKind)
process.Leak().HeapPtr = rt_new_heap(kUserHeapUser | kUserHeapRw | kUserHeapShared);
else
process.Leak().HeapPtr = rt_new_heap(kUserHeapDriver | kUserHeapRw);
diff --git a/Kernel/Sources/ProcessTeam.cxx b/Kernel/Sources/ProcessTeam.cxx
index 7e311399..068e0dbb 100644
--- a/Kernel/Sources/ProcessTeam.cxx
+++ b/Kernel/Sources/ProcessTeam.cxx
@@ -9,7 +9,7 @@
/// @brief Process teams implementation.
/***********************************************************************************/
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
namespace NewOS
{
diff --git a/Kernel/Sources/SMPManager.cxx b/Kernel/Sources/SMPManager.cxx
index b2f239e3..29e0fa26 100644
--- a/Kernel/Sources/SMPManager.cxx
+++ b/Kernel/Sources/SMPManager.cxx
@@ -5,7 +5,7 @@
------------------------------------------- */
#include <ArchKit/ArchKit.hpp>
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
#include <KernelKit/SMPManager.hpp>
///! BUGS: 0
@@ -95,7 +95,6 @@ namespace NewOS
{
/// Keep the arguments, switch the base pointer, stack pointer
/// fs and gs registers.
-
fStack->Rbp = stack->Rbp;
fStack->Rsp = stack->Rsp;
fStack->Fs = stack->Fs;
@@ -103,6 +102,7 @@ namespace NewOS
}
rt_do_context_switch(fStack);
+
return true;
}
@@ -172,6 +172,8 @@ namespace NewOS
rt_copy_memory(stack, fThreadList[idx].Leak().Leak().fStack,
sizeof(HAL::StackFrame));
+ fThreadList[idx].Leak().Leak().Switch(fThreadList[idx].Leak().Leak().fStack);
+
fThreadList[idx].Leak().Leak().fPID = ProcessHelper::GetCurrentPID();
fThreadList[idx].Leak().Leak().Busy(false);
diff --git a/Kernel/Sources/Semaphore.cxx b/Kernel/Sources/Semaphore.cxx
index 7bd1d513..e2e135d0 100644
--- a/Kernel/Sources/Semaphore.cxx
+++ b/Kernel/Sources/Semaphore.cxx
@@ -4,7 +4,7 @@
------------------------------------------- */
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
#include <KernelKit/Semaphore.hpp>
#include <KernelKit/Timer.hpp>
diff --git a/Kernel/Sources/ThreadLocalStorage.cxx b/Kernel/Sources/ThreadLocalStorage.cxx
index 2d7e61eb..00305006 100644
--- a/Kernel/Sources/ThreadLocalStorage.cxx
+++ b/Kernel/Sources/ThreadLocalStorage.cxx
@@ -7,7 +7,7 @@
* ========================================================
*/
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
#include <KernelKit/ThreadLocalStorage.hxx>
///! BUGS: 0
diff --git a/Kernel/Sources/UserHeap.cxx b/Kernel/Sources/UserHeap.cxx
index da5d7b5a..64b75641 100644
--- a/Kernel/Sources/UserHeap.cxx
+++ b/Kernel/Sources/UserHeap.cxx
@@ -4,7 +4,7 @@
------------------------------------------- */
-#include <KernelKit/ProcessScheduler.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
#include <KernelKit/UserHeap.hpp>
#include <NewKit/PageManager.hpp>
diff --git a/Kernel/makefile b/Kernel/makefile
index b7749100..14bd1cae 100644
--- a/Kernel/makefile
+++ b/Kernel/makefile
@@ -69,7 +69,7 @@ link-amd64-epm:
.PHONY: all
all: newos-amd64-epm link-amd64-epm
- @echo "NewKernel => OK."
+ @echo "NewOSKrnl => OK."
.PHONY: help
help: