summaryrefslogtreecommitdiffhomepage
path: root/Kernel/Sources
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Sources')
-rw-r--r--Kernel/Sources/FS/NewFS.cxx27
-rw-r--r--Kernel/Sources/Network/IPCEP.cxx36
-rw-r--r--Kernel/Sources/ProcessScheduler.cxx12
-rw-r--r--Kernel/Sources/ProcessTeam.cxx7
4 files changed, 64 insertions, 18 deletions
diff --git a/Kernel/Sources/FS/NewFS.cxx b/Kernel/Sources/FS/NewFS.cxx
index 4e212164..33857590 100644
--- a/Kernel/Sources/FS/NewFS.cxx
+++ b/Kernel/Sources/FS/NewFS.cxx
@@ -16,6 +16,7 @@
#include <NewKit/String.hpp>
#include <NewKit/Utils.hpp>
#include <FirmwareKit/EPM.hxx>
+#include <KernelKit/ProcessScheduler.hxx>
using namespace NewOS;
@@ -167,12 +168,12 @@ _Output NewFork* NewFSParser::FindFork(_Input NewCatalog* catalog,
switch (res)
{
case 1:
- DbgLastError() = kErrorDiskReadOnly;
+ ErrLocal() = kErrorDiskReadOnly;
break;
case 2:
- DbgLastError() = kErrorDiskIsFull;
+ ErrLocal() = kErrorDiskIsFull;
break;
- DbgLastError() = kErrorNoSuchDisk;
+ ErrLocal() = kErrorNoSuchDisk;
break;
default:
@@ -241,7 +242,7 @@ _Output NewCatalog* NewFSParser::CreateCatalog(_Input const char* name,
if (*parentName == 0)
{
- DbgLastError() = kErrorFileNotFound;
+ ErrLocal() = kErrorFileNotFound;
return nullptr;
}
@@ -414,7 +415,7 @@ _Output NewCatalog* NewFSParser::CreateCatalog(_Input const char* name,
/// @brief Make a EPM+NewFS drive out of the disk.
/// @param drive The drive to write on.
-/// @return If it was sucessful, see DbgLastError().
+/// @return If it was sucessful, see ErrLocal().
bool NewFSParser::Format(_Input _Output DriveTrait* drive)
{
/// verify disk.
@@ -426,7 +427,7 @@ bool NewFSParser::Format(_Input _Output DriveTrait* drive)
/// if disk isn't good, then error out.
if (false == drive->fPacket.fPacketGood)
{
- DbgLastError() = kErrorDiskIsCorrupted;
+ ErrLocal() = kErrorDiskIsCorrupted;
return false;
}
@@ -565,7 +566,7 @@ bool NewFSParser::WriteCatalog(_Input _Output NewCatalog* catalog, voidPtr data,
/// sanity check the fork.
if (forkData->DataOffset <= kNewFSCatalogStartAddress)
{
- DbgLastError() = kErrorDiskIsCorrupted;
+ ErrLocal() = kErrorDiskIsCorrupted;
kcout << "newoskrnl: Invalid fork offset.\r";
@@ -771,7 +772,7 @@ Boolean NewFSParser::RemoveCatalog(_Input const Char* catalogName)
if (!catalogName ||
StringBuilder::Equals(catalogName, NewFilesystemHelper::Root()))
{
- DbgLastError() = kErrorInternal;
+ ErrLocal() = kErrorInternal;
return false;
}
@@ -835,7 +836,7 @@ VoidPtr NewFSParser::ReadCatalog(_Input _Output NewCatalog* catalog,
{
if (!catalog)
{
- DbgLastError() = kErrorFileNotFound;
+ ErrLocal() = kErrorFileNotFound;
return nullptr;
}
@@ -913,11 +914,11 @@ bool NewFSParser::Seek(_Input _Output NewCatalog* catalog, SizeT off)
{
if (!catalog)
{
- DbgLastError() = kErrorFileNotFound;
+ ErrLocal() = kErrorFileNotFound;
return false;
}
- DbgLastError() = kErrorUnimplemented;
+ ErrLocal() = kErrorUnimplemented;
return false;
}
@@ -931,11 +932,11 @@ SizeT NewFSParser::Tell(_Input _Output NewCatalog* catalog)
{
if (!catalog)
{
- DbgLastError() = kErrorFileNotFound;
+ ErrLocal() = kErrorFileNotFound;
return 0;
}
- DbgLastError() = kErrorUnimplemented;
+ ErrLocal() = kErrorUnimplemented;
return 0;
}
diff --git a/Kernel/Sources/Network/IPCEP.cxx b/Kernel/Sources/Network/IPCEP.cxx
index e3a40fb9..0cd9d778 100644
--- a/Kernel/Sources/Network/IPCEP.cxx
+++ b/Kernel/Sources/Network/IPCEP.cxx
@@ -5,3 +5,39 @@
------------------------------------------- */
#include <NetworkKit/IPCEP.hxx>
+
+using namespace NewOS;
+
+Bool ipc_sanitize_packet(IPCEPMessageHeader* pckt)
+{
+ if (!pckt) return false;
+
+ auto endian = DEDUCE_ENDIAN(pckt, ((char*)pckt)[0]);
+
+ switch (endian)
+ {
+ case Endian::kEndianBig:
+ {
+ if (pckt->IpcEndianess == eIPCEPLittleEndian)
+ return false;
+
+ break;
+ }
+ case Endian::kEndianLittle:
+ {
+ if (pckt->IpcEndianess == eIPCEPBigEndian)
+ return false;
+
+ break;
+ }
+ case Endian::kEndianMixed:
+ break;
+ default:
+ return false;
+ }
+
+ if (pckt->IpcFrom == pckt->IpcTo) return false;
+ if (pckt->IpcPacketSize > cIPCEPMsgSize) return false;
+
+ return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cRemoteHeaderMagic;
+}
diff --git a/Kernel/Sources/ProcessScheduler.cxx b/Kernel/Sources/ProcessScheduler.cxx
index ca9a3435..ddeff7f2 100644
--- a/Kernel/Sources/ProcessScheduler.cxx
+++ b/Kernel/Sources/ProcessScheduler.cxx
@@ -55,6 +55,8 @@ namespace NewOS
this->Exit(kErrorProcessFault);
}
+ Int32& ProcessHeader::GetLocalCode() noexcept { return fLocalCode; }
+
void ProcessHeader::Wake(const bool should_wakeup)
{
this->Status =
@@ -69,7 +71,7 @@ namespace NewOS
{
if (this->FreeMemory < 1)
{
- DbgLastError() = kErrorHeapOutOfMemory;
+ ErrLocal() = kErrorHeapOutOfMemory;
/* we're going out of memory */
this->Crash();
@@ -134,19 +136,19 @@ namespace NewOS
}
/// @brief process name getter.
- const Char* ProcessHeader::GetName()
+ const Char* ProcessHeader::GetName() noexcept
{
return this->Name;
}
/// @brief process selector getter.
- const ProcessSelector& ProcessHeader::GetSelector()
+ const ProcessSelector& ProcessHeader::GetSelector() noexcept
{
return this->Selector;
}
/// @brief process status getter.
- const ProcessStatus& ProcessHeader::GetStatus()
+ const ProcessStatus& ProcessHeader::GetStatus() noexcept
{
return this->Status;
}
@@ -156,7 +158,7 @@ namespace NewOS
/**
@brief Affinity is the time slot allowed for the process.
*/
- const AffinityKind& ProcessHeader::GetAffinity()
+ const AffinityKind& ProcessHeader::GetAffinity() noexcept
{
return this->Affinity;
}
diff --git a/Kernel/Sources/ProcessTeam.cxx b/Kernel/Sources/ProcessTeam.cxx
index 30c791b2..f01841a6 100644
--- a/Kernel/Sources/ProcessTeam.cxx
+++ b/Kernel/Sources/ProcessTeam.cxx
@@ -20,6 +20,13 @@ namespace NewOS
return mProcessList;
}
+ /// @brief Get team ID.
+ /// @return The team's ID.
+ UInt64& ProcessTeam::Id() noexcept
+ {
+ return mTeamId;
+ }
+
/// @brief Current process getter.
/// @return The current process header.
Ref<ProcessHeader>& ProcessTeam::AsRef()