summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/SCIKit/Foundation.h2
-rw-r--r--dev/SCIKit/LPC.h5
-rw-r--r--dev/SCIKit/Macros.h17
-rw-r--r--dev/SCIKit/makefile12
-rw-r--r--dev/ZKAKit/CFKit/Property.h4
-rw-r--r--dev/ZKAKit/KernelKit/UserProcessScheduler.h2
-rw-r--r--dev/ZKAKit/src/PEFCodeMgr.cc17
-rw-r--r--dev/ZKAKit/src/PRDT.cc2
-rw-r--r--dev/ZKAKit/src/Pmm.cc6
-rw-r--r--dev/ZKAKit/src/Property.cc20
-rw-r--r--dev/ZKAKit/src/Semaphore.cc33
-rw-r--r--dev/ZKAKit/src/Stop.cc38
-rw-r--r--dev/ZKAKit/src/UserProcessScheduler.cc26
13 files changed, 109 insertions, 75 deletions
diff --git a/dev/SCIKit/Foundation.h b/dev/SCIKit/Foundation.h
index aeef7928..0bce54a2 100644
--- a/dev/SCIKit/Foundation.h
+++ b/dev/SCIKit/Foundation.h
@@ -11,8 +11,6 @@ Purpose: SCIKit Foundation header.
#define SCIKIT_FOUNDATION_H
#include <SCIKit/Macros.h>
-#include <SCIKit/CompilerHint.h>
-#include <SCIKit/LPC.h>
// ------------------------------------------------------------------------------------------ //
/// @brief Dynamic Loader API.
diff --git a/dev/SCIKit/LPC.h b/dev/SCIKit/LPC.h
index c81554d4..95cdad90 100644
--- a/dev/SCIKit/LPC.h
+++ b/dev/SCIKit/LPC.h
@@ -6,9 +6,10 @@
#pragma once
+#include <SCIKit/Macros.h>
+
/// @file LPC.h
-/// @brief Local Process Codes.
-///
+/// @brief Local Process Code type and values.
#define ErrLocalIsOk() (kLastError == kErrorSuccess)
#define ErrLocalFailed() (kLastError != kErrorSuccess)
#define ErrLocal() (kLastError)
diff --git a/dev/SCIKit/Macros.h b/dev/SCIKit/Macros.h
index 66263f34..114b74ef 100644
--- a/dev/SCIKit/Macros.h
+++ b/dev/SCIKit/Macros.h
@@ -1,13 +1,18 @@
#pragma once
-// ------------------------------------------------------------------------------------------ //
-/// @brief Handle Type and Macros definitions.
-// ------------------------------------------------------------------------------------------ //
+/***********************************************************************************/
+/// @file SCIKit/Macros.h
+/// @brief Macros and core types.
+/***********************************************************************************/
+
+#include <SCIKit/CompilerHint.h>
#define ATTRIBUTE(X) __attribute__((X))
#define IMPORT_CXX extern "C++"
#define IMPORT_C extern "C"
+#define DEPRECATED ATTRIBUTE(deprecated)
+
typedef bool Bool;
typedef void Void;
@@ -29,10 +34,8 @@ typedef char Char;
typedef VoidPtr SCIObject;
-typedef SCIObject DLLObject;
typedef SCIObject IOObject;
-typedef SCIObject SCMObject;
+typedef IOObject FSObject;
+typedef SCIObject DLLObject;
typedef SCIObject ThreadObject;
typedef SCIObject SocketObject;
-typedef SCIObject ShellObject;
-typedef SCIObject UIObject;
diff --git a/dev/SCIKit/makefile b/dev/SCIKit/makefile
deleted file mode 100644
index 1974aed3..00000000
--- a/dev/SCIKit/makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-######################
-# (C) ZKA
-# SCIKit makefile.
-######################
-
-CC=clang++
-FLAGS=-I../ -shared -fPIC
-OUTPUT=SCIKit.dll
-
-.PHONY: build-sci
-build-sci:
- $(CC) $(wildcard src/*.cc) $(FLAGS) -o $(OUTPUT)
diff --git a/dev/ZKAKit/CFKit/Property.h b/dev/ZKAKit/CFKit/Property.h
index f2e4c859..212d772d 100644
--- a/dev/ZKAKit/CFKit/Property.h
+++ b/dev/ZKAKit/CFKit/Property.h
@@ -26,7 +26,7 @@ namespace CFKit
class Property
{
public:
- Property() = default;
+ Property();
virtual ~Property();
public:
@@ -39,7 +39,7 @@ namespace CFKit
private:
KString fName{kMaxPropLen};
- PropertyId fAction{No};
+ PropertyId fValue{0UL};
};
template <SizeT N>
diff --git a/dev/ZKAKit/KernelKit/UserProcessScheduler.h b/dev/ZKAKit/KernelKit/UserProcessScheduler.h
index 906a378b..e55a7477 100644
--- a/dev/ZKAKit/KernelKit/UserProcessScheduler.h
+++ b/dev/ZKAKit/KernelKit/UserProcessScheduler.h
@@ -167,7 +167,7 @@ namespace Kernel
USER_PROCESS_HEAP* MemoryHeap{nullptr};
- UIntPtr VMRegister{0UL};
+ VoidPtr VMRegister{0UL};
enum
{
diff --git a/dev/ZKAKit/src/PEFCodeMgr.cc b/dev/ZKAKit/src/PEFCodeMgr.cc
index 311c2d2d..f929a01f 100644
--- a/dev/ZKAKit/src/PEFCodeMgr.cc
+++ b/dev/ZKAKit/src/PEFCodeMgr.cc
@@ -22,7 +22,9 @@ namespace Kernel
{
namespace Detail
{
- /// @brief Get the PEF platform signature according to the compiled backebnd
+ /***********************************************************************************/
+ /// @brief Get the PEF platform signature according to the compiled architecture.
+ /***********************************************************************************/
UInt32 ldr_get_platform(void) noexcept
{
#if defined(__ZKA_32X0__)
@@ -41,8 +43,10 @@ namespace Kernel
}
} // namespace Detail
+ /***********************************************************************************/
/// @brief PEF loader constructor w/ blob.
- /// @param blob
+ /// @param blob file blob.
+ /***********************************************************************************/
PEFLoader::PEFLoader(const VoidPtr blob)
: fCachedBlob(blob)
{
@@ -50,8 +54,10 @@ namespace Kernel
fBad = false;
}
+ /***********************************************************************************/
/// @brief PEF loader constructor.
/// @param path the filesystem path.
+ /***********************************************************************************/
PEFLoader::PEFLoader(const Char* path)
: fCachedBlob(nullptr), fBad(false), fFatBinary(false)
{
@@ -94,7 +100,9 @@ namespace Kernel
fCachedBlob = nullptr;
}
+ /***********************************************************************************/
/// @brief PEF destructor.
+ /***********************************************************************************/
PEFLoader::~PEFLoader()
{
if (fCachedBlob)
@@ -103,6 +111,11 @@ namespace Kernel
fFile.Delete();
}
+ /***********************************************************************************/
+ /// @brief Finds the symbol according to it's name.
+ /// @param name name of symbol.
+ /// @param kind kind of symbol we want.
+ /***********************************************************************************/
VoidPtr PEFLoader::FindSymbol(const Char* name, Int32 kind)
{
if (!fCachedBlob || fBad || !name)
diff --git a/dev/ZKAKit/src/PRDT.cc b/dev/ZKAKit/src/PRDT.cc
index 3aa07bb1..7df6875a 100644
--- a/dev/ZKAKit/src/PRDT.cc
+++ b/dev/ZKAKit/src/PRDT.cc
@@ -10,9 +10,11 @@
namespace Kernel
{
+ /***********************************************************************************/
/// @brief constructs a new PRD.
/// @param prd PRD reference.
/// @note This doesnt construct a valid, please fill it by yourself.
+ /***********************************************************************************/
void construct_prdt(Ref<PRDT>& prd)
{
prd.Leak().fPhysAddress = 0x0;
diff --git a/dev/ZKAKit/src/Pmm.cc b/dev/ZKAKit/src/Pmm.cc
index 4eb30df8..e9a9c9d3 100644
--- a/dev/ZKAKit/src/Pmm.cc
+++ b/dev/ZKAKit/src/Pmm.cc
@@ -17,7 +17,9 @@
namespace Kernel
{
+ /***********************************************************************************/
/// @brief Pmm constructor.
+ /***********************************************************************************/
Pmm::Pmm()
: fPageMgr()
{
@@ -26,9 +28,11 @@ namespace Kernel
Pmm::~Pmm() = default;
- /* If this returns Null pointer, enter emergency mode */
+ /***********************************************************************************/
+ /// @param If this returns Null pointer, enter emergency mode.
/// @param user is this a user page?
/// @param readWrite is it r/w?
+ /***********************************************************************************/
Ref<PTEWrapper> Pmm::RequestPage(Boolean user, Boolean readWrite)
{
PTEWrapper pt = fPageMgr.Leak().Request(user, readWrite, false, kPageSize);
diff --git a/dev/ZKAKit/src/Property.cc b/dev/ZKAKit/src/Property.cc
index f4799b97..cd9f0833 100644
--- a/dev/ZKAKit/src/Property.cc
+++ b/dev/ZKAKit/src/Property.cc
@@ -8,20 +8,38 @@
namespace CFKit
{
+ /***********************************************************************************/
+ /// @brief Destructor.
+ /***********************************************************************************/
Property::~Property() = default;
+ /***********************************************************************************/
+ /// @brief Constructor.
+ /***********************************************************************************/
+ Property::Property() = default;
+
+ /***********************************************************************************/
+ /// @brief Check if property's name equals to name.
+ /// @param name string to check.
+ /***********************************************************************************/
Bool Property::StringEquals(KString& name)
{
return this->fName && this->fName == name;
}
+ /***********************************************************************************/
+ /// @brief Gets the key (name) of property.
+ /***********************************************************************************/
KString& Property::GetKey()
{
return this->fName;
}
+ /***********************************************************************************/
+ /// @brief Gets the value of the property.
+ /***********************************************************************************/
PropertyId& Property::GetValue()
{
- return fAction;
+ return fValue;
}
} // namespace CFKit
diff --git a/dev/ZKAKit/src/Semaphore.cc b/dev/ZKAKit/src/Semaphore.cc
index b32cd3c6..29490498 100644
--- a/dev/ZKAKit/src/Semaphore.cc
+++ b/dev/ZKAKit/src/Semaphore.cc
@@ -9,6 +9,9 @@
namespace Kernel
{
+ /***********************************************************************************/
+ /// @brief Unlocks process out of the semaphore.
+ /***********************************************************************************/
Bool Semaphore::Unlock() noexcept
{
if (fLockingProcess)
@@ -19,28 +22,37 @@ namespace Kernel
return Yes;
}
+ /***********************************************************************************/
+ /// @brief Locks process in the semaphore.
+ /***********************************************************************************/
Bool Semaphore::Lock(UserProcess* process)
{
if (!process || fLockingProcess)
- return false;
+ return No;
fLockingProcess = process;
- return true;
+ return Yes;
}
+ /***********************************************************************************/
+ /// @brief Checks if process is locked.
+ /***********************************************************************************/
Bool Semaphore::IsLocked() const
{
return fLockingProcess;
}
+ /***********************************************************************************/
+ /// @brief Try lock or wait.
+ /***********************************************************************************/
Bool Semaphore::LockOrWait(UserProcess* process, TimerInterface* timer)
{
if (process == nullptr)
- return false;
+ return No;
if (timer == nullptr)
- return false;
+ return No;
this->Lock(process);
@@ -49,16 +61,11 @@ namespace Kernel
return this->Lock(process);
}
- /// @brief Wait with process, either wait for it to be being invalid, or not being run.
+ /***********************************************************************************/
+ /// @brief Wait for process to be free.
+ /***********************************************************************************/
Void Semaphore::WaitForProcess() noexcept
{
- while (fLockingProcess)
- {
- if (fLockingProcess->GetStatus() != ProcessStatusKind::kRunning)
- {
- this->Unlock();
- break;
- }
- }
+ while (fLockingProcess);
}
} // namespace Kernel
diff --git a/dev/ZKAKit/src/Stop.cc b/dev/ZKAKit/src/Stop.cc
index 53531cdd..1374c842 100644
--- a/dev/ZKAKit/src/Stop.cc
+++ b/dev/ZKAKit/src/Stop.cc
@@ -21,75 +21,73 @@
namespace Kernel
{
+ /***********************************************************************************/
+ /// @brief Stops execution of the kernel.
+ /// @param id kernel stop ID.
+ /***********************************************************************************/
Void ke_stop(const Kernel::Int32& id)
{
CGInit();
auto panic_text = RGB(0xff, 0xff, 0xff);
- auto start_y = 10;
+ auto start_y = 30;
auto x = 10;
- CGDrawString("minoskrnl.exe, bug check error raised, stopping...", start_y, x, panic_text);
+ CGDrawString("Kernel Panic!", start_y, x, panic_text);
start_y += 10;
- // simply offset from previous string and then write the website.
- CGDrawString("Please visit: ", start_y, x, panic_text);
- CGDrawString(kWebsiteURL, start_y, x + (FONT_SIZE_X * rt_string_len("Please visit: ")), panic_text);
-
CGFini();
- start_y += 10;
-
// show text according to error id.
switch (id)
{
case RUNTIME_CHECK_PROCESS: {
- CGDrawString("0x00000008 Invalid process behavior, aborting.", start_y, x, panic_text);
+ CGDrawString("0x00000008: Invalid process behavior.", start_y, x, panic_text);
break;
}
case RUNTIME_CHECK_ACPI: {
- CGDrawString("0x00000006 ACPI configuration error.", start_y, x, panic_text);
+ CGDrawString("0x00000006: ACPI configuration error.", start_y, x, panic_text);
break;
}
case RUNTIME_CHECK_PAGE: {
- CGDrawString("0x0000000B Write/Read in non paged area.", start_y, x, panic_text);
+ CGDrawString("0x0000000B: Write/Read in non paged area.", start_y, x, panic_text);
break;
}
case RUNTIME_CHECK_FILESYSTEM: {
- CGDrawString("0x0000000A Filesystem error.", start_y, x, panic_text);
+ CGDrawString("0x0000000A: Filesystem driver error.", start_y, x, panic_text);
break;
}
case RUNTIME_CHECK_POINTER: {
- CGDrawString("0x00000000 Heap is corrupted.", start_y, x, panic_text);
+ CGDrawString("0x00000000: Kernel heap is corrupted.", start_y, x, panic_text);
break;
}
case RUNTIME_CHECK_BAD_BEHAVIOR: {
- CGDrawString("0x00000009 Bad Behavior.", start_y, x, panic_text);
+ CGDrawString("0x00000009: Bad behavior.", start_y, x, panic_text);
break;
}
case RUNTIME_CHECK_BOOTSTRAP: {
- CGDrawString("0x0000000A Boot code has finished executing, waiting for scheduler and other cores.", start_y, x, panic_text);
+ CGDrawString("0x0000000A: Boot code has finished executing, waiting for scheduler and other cores.", start_y, x, panic_text);
return;
}
case RUNTIME_CHECK_HANDSHAKE: {
- CGDrawString("0x00000005 Handshake fault.", start_y, x, panic_text);
+ CGDrawString("0x00000005: Handshake fault.", start_y, x, panic_text);
break;
}
case RUNTIME_CHECK_IPC: {
- CGDrawString("0x00000003 Bad IPC/XPCOM message.", start_y, x, panic_text);
+ CGDrawString("0x00000003: Bad LPC message.", start_y, x, panic_text);
break;
}
case RUNTIME_CHECK_INVALID_PRIVILEGE: {
- CGDrawString("0x00000007 Privilege access violation.", start_y, x, panic_text);
+ CGDrawString("0x00000007: Privilege access violation.", start_y, x, panic_text);
break;
case RUNTIME_CHECK_UNEXCPECTED: {
- CGDrawString("0x0000000B Unexpected violation.", start_y, x, panic_text);
+ CGDrawString("0x0000000B: Unexpected violation.", start_y, x, panic_text);
break;
}
case RUNTIME_CHECK_VIRTUAL_OUT_OF_MEM: {
- CGDrawString("0x10000001 Out of virtual memory.", start_y, x, panic_text);
+ CGDrawString("0x10000001: Out of virtual memory.", start_y, x, panic_text);
break;
}
diff --git a/dev/ZKAKit/src/UserProcessScheduler.cc b/dev/ZKAKit/src/UserProcessScheduler.cc
index 1a060041..4550af4e 100644
--- a/dev/ZKAKit/src/UserProcessScheduler.cc
+++ b/dev/ZKAKit/src/UserProcessScheduler.cc
@@ -118,11 +118,11 @@ namespace Kernel
{
#ifdef __ZKA_AMD64__
auto vm_register = hal_read_cr3();
- hal_write_cr3(reinterpret_cast<VoidPtr>(this->VMRegister));
+ hal_write_cr3(this->VMRegister);
auto ptr = mm_new_heap(sz + pad_amount, Yes, Yes);
- hal_write_cr3(reinterpret_cast<VoidPtr>(vm_register));
+ hal_write_cr3(vm_register);
#else
auto ptr = mm_new_heap(sz + pad_amount, Yes, Yes);
#endif
@@ -183,7 +183,7 @@ namespace Kernel
{
#ifdef __ZKA_AMD64__
auto pd = hal_read_cr3();
- hal_write_cr3(reinterpret_cast<VoidPtr>(this->VMRegister));
+ hal_write_cr3(this->VMRegister);
auto ret = mm_delete_heap(entry->MemoryEntry);
@@ -262,7 +262,7 @@ namespace Kernel
{
#ifdef __ZKA_AMD64__
auto pd = hal_read_cr3();
- hal_write_cr3(reinterpret_cast<VoidPtr>(this->VMRegister));
+ hal_write_cr3(this->VMRegister);
#endif
MUST_PASS(mm_delete_heap(memory_list->MemoryEntry));
@@ -281,7 +281,7 @@ namespace Kernel
}
//! Free the memory's page directory.
- HAL::mm_free_bitmap(reinterpret_cast<VoidPtr>(this->VMRegister));
+ HAL::mm_free_bitmap(this->VMRegister);
//! Delete image if not done already.
if (this->Code && mm_is_valid_heap(this->Code))
@@ -325,10 +325,8 @@ namespace Kernel
ProcessID UserProcessScheduler::Add(UserProcess* process)
{
- kcout << "Create VMRegister of: " << process->Name << endl;
-
#ifdef __ZKA_AMD64__
- process->VMRegister = reinterpret_cast<UIntPtr>(mm_new_heap(sizeof(PDE), No, Yes));
+ process->VMRegister = mm_new_heap(sizeof(PDE), No, Yes);
if (!process->VMRegister)
{
@@ -337,7 +335,7 @@ namespace Kernel
}
#endif // __ZKA_AMD64__
- kcout << "Create StackFrame of: " << process->Name << endl;
+ kcout << "Create page directory for: " << process->Name << endl;
process->StackFrame = reinterpret_cast<HAL::StackFramePtr>(mm_new_heap(sizeof(HAL::StackFrame), Yes, Yes));
@@ -347,11 +345,15 @@ namespace Kernel
return -kErrorProcessFault;
}
+ kcout << "Create stack for: " << process->Name << endl;
+
// Create heap according to type of process->
if (process->Kind == UserProcess::kExectuableDLLKind)
{
- kcout << "Create delegate dylib for: " << process->Name << endl;
process->PefDLLDelegate = rtl_init_dll(process);
+ MUST_PASS(process->PefDLLDelegate);
+
+ kcout << "Create delegate dylib for: " << process->Name << endl;
}
process->StackReserve = new UInt8[process->StackSize];
@@ -362,14 +364,14 @@ namespace Kernel
HAL::mm_map_page((VoidPtr)process->StackReserve, flags);
- kcout << "Validate stack reserve: " << number((UIntPtr)process->StackReserve) << endl;
-
if (!process->StackReserve)
{
process->Crash();
return -kErrorProcessFault;
}
+ kcout << "Created stack reserve for: " << process->Name << endl;
+
auto pid = kProcessIDCounter;
process->ProcessId = pid;