summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/DDK/KernelDev.h2
-rw-r--r--dev/DDK/KernelStd.h2
-rw-r--r--dev/SCI/sci_base.hxx24
-rw-r--r--dev/SCI/xpcom_core.hxx (renamed from dev/SCI/scm_core.hxx)8
-rw-r--r--dev/SCI/xpcom_sms.idl (renamed from dev/SCI/scm_xpcom.idl)4
-rw-r--r--dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm9
-rw-r--r--dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm2
-rw-r--r--dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx18
-rw-r--r--dev/ZKA/HALKit/AMD64/HalPageAlloc.hxx3
-rw-r--r--dev/ZKA/NetworkKit/IPC.hxx10
-rw-r--r--dev/ZKA/Sources/Heap.cxx9
-rw-r--r--dev/ZKA/Sources/Network/IPC.cxx6
-rw-r--r--dev/ZKA/Sources/PageManager.cxx3
13 files changed, 67 insertions, 33 deletions
diff --git a/dev/DDK/KernelDev.h b/dev/DDK/KernelDev.h
index ce7b1a2d..2e166ace 100644
--- a/dev/DDK/KernelDev.h
+++ b/dev/DDK/KernelDev.h
@@ -13,7 +13,7 @@
struct _KERNEL_DEVICE;
/// @brief Kernel Device driver.
-typedef struct _KERNEL_DEVICE
+typedef struct _KERNEL_DEVICE DK_FINAL
{
char name[255]; // the device name. Could be /./DEVICE_NAME/
void* (*read)(void* arg, int len); // read from device.
diff --git a/dev/DDK/KernelStd.h b/dev/DDK/KernelStd.h
index d5350c8e..ebc8f47b 100644
--- a/dev/DDK/KernelStd.h
+++ b/dev/DDK/KernelStd.h
@@ -32,7 +32,7 @@ struct DDK_PROPERTY_RECORD DK_FINAL
{
char* p_name;
void* p_object;
- void* p_scm_object;
+ void* p_xpcom_object;
};
/// \brief DDK status structure (__at_enable, __at_disable...)
diff --git a/dev/SCI/sci_base.hxx b/dev/SCI/sci_base.hxx
index 9a3038dc..e3bc39de 100644
--- a/dev/SCI/sci_base.hxx
+++ b/dev/SCI/sci_base.hxx
@@ -37,7 +37,7 @@ typedef char Char;
#include <SCI/sci_err.hxx>
#ifdef __SCI_IMPL__
-#include <SCI/scm_core.hxx>
+#include <SCI/xpcom_core.hxx>
#else
class IUnknown; // Refrenced from an IDB entry.
class UnknownUCLSID; // From the IDB, the constructor of the object, e.g: WordUCLSID.
@@ -49,10 +49,10 @@ class UUID;
/// @param uclsidOfCls
/// @return
template <typename TCLS, typename UCLSID, typename... Args>
-TCLS* ScmQueryInterface(UCLSID uclsidOfCls, Args... args);
+TCLS* XPCOMQueryInterface(UCLSID uclsidOfCls, Args... args);
template <typename TCLS>
-SInt32 ScmReleaseClass(TCLS** cls);
+SInt32 XPCOMReleaseClass(TCLS** cls);
/// @brief Release SCM class.
/// @tparam TCLS
@@ -169,23 +169,23 @@ IMPORT_C UInt32 TlsInstallIB(UInt0);
/// @param uclsidOfCls UCLS factory class
/// @return TCLS interface
template <typename TCLS, typename UCLSID, typename... Args>
-TCLS* ScmQueryInterface(_Input UCLSID* uclsidOfCls, _Input Args&&... args);
+TCLS* XPCOMQueryInterface(_Input UCLSID* uclsidOfCls, _Input Args&&... args);
/// @brief Release SCM object.
/// @tparam TCLS the class type.
/// @param cls the class to release.
/// @return status code.
template <typename TCLS>
-SInt32 ScmReleaseClass(_Input TCLS* cls);
+SInt32 XPCOMReleaseClass(_Input TCLS* cls);
/// @brief Creates an SCM instance in the process.
/// @param handle_instance the SCM handle.
/// @param flags the SCM flags.
-IMPORT_C SInt32 ScmCreateInstance(_Input UInt32 flags, _Output ZKAObject* handle_instance);
+IMPORT_C SInt32 XPCOMCreateInstance(_Input UInt32 flags, _Output ZKAObject* handle_instance);
/// @brief Destroys an SCM instance of the process.
/// @param handle_instance the SCM handle.
-IMPORT_C UInt0 ScmDestroyInstance(_Input ZKAObject handle_instance);
+IMPORT_C UInt0 XPCOMDestroyInstance(_Input ZKAObject handle_instance);
// ------------------------------------------------------------------------
// Memory Management API.
@@ -195,12 +195,18 @@ IMPORT_C UInt0 ScmDestroyInstance(_Input ZKAObject handle_instance);
/// @param len the length of it.
/// @param flags the flags of it.
/// @return heap pointer.
-IMPORT_C VoidPtr RtlCreateHeap(_Input SizeT len, _Input UInt32 flags);
+IMPORT_C VoidPtr MmCreateHeap(_Input SizeT len, _Input UInt32 flags);
/// @brief Destroys the pointer
/// @param heap the heap itself.
/// @return void.
-IMPORT_C UInt0 RtlDestroyHeap(_Input VoidPtr heap);
+IMPORT_C UInt0 MmDestroyHeap(_Input VoidPtr heap);
+
+/// @brief Change protection flags of memory region.
+IMPORT_C UInt32 MmChangeHeapFlags(_Input VoidPtr heap, _Input UInt32 flags);
+
+/// @brief Fill memory region with CRC32.
+IMPORT_C UInt32 MmFillCRC32Heap(_Input VoidPtr heap);
// ------------------------------------------------------------------------
// Error handling API.
diff --git a/dev/SCI/scm_core.hxx b/dev/SCI/xpcom_core.hxx
index db3b9c69..f48fd30b 100644
--- a/dev/SCI/scm_core.hxx
+++ b/dev/SCI/xpcom_core.hxx
@@ -17,13 +17,11 @@ Purpose: Base code of SCM.
#warning ! You may be using the clang version of the ZKA kit, please be cautious that some thing mayn't be present. !
#endif // !__NDK__
-// Interfaces are divided between classes.
-// So that they aren't too big.
-
protocol IUnknown; // Refrenced from an IDB entry.
protocol UnknownUCLSID; // From the IDB, the constructor of the object, e.g: TextUCLSID.
object UUID;
+/// @brief Unknown XPCOM interface
protocol clsid("d7c144b6-0792-44b8-b06b-02b227b547df") IUnknown
{
public:
@@ -45,7 +43,7 @@ public:
/// @param uclsidOfCls UCLS factory class
/// @return TCLS interface
template <typename TCLS, typename UCLSID, typename... Args>
-inline TCLS* ScmQueryInterface(UCLSID* uclsidOfCls, Args&&... args)
+inline TCLS* XPCOMQueryInterface(UCLSID* uclsidOfCls, Args&&... args)
{
uclsidOfCls->AddRef();
return uclsidOfCls->QueryInterfaceWithArgs(args...);
@@ -56,7 +54,7 @@ inline TCLS* ScmQueryInterface(UCLSID* uclsidOfCls, Args&&... args)
/// @param cls the class to release.
/// @return status code.
template <typename TCLS>
-inline SInt32 ScmReleaseClass(TCLS** cls)
+inline SInt32 XPCOMReleaseClass(TCLS** cls)
{
if (!cls)
return -1;
diff --git a/dev/SCI/scm_xpcom.idl b/dev/SCI/xpcom_sms.idl
index 1fdbd6c9..8c95616b 100644
--- a/dev/SCI/scm_xpcom.idl
+++ b/dev/SCI/xpcom_sms.idl
@@ -25,10 +25,8 @@ Purpose: Base code of SCM.
#warning ! You may be using the clang version of the ZKA kit, please be cautious that some thing mayn't be present. !
#endif // !__NDK__
-protocol IPXCOMSocket;
-
clsid("0943A614-0201-4107-8F8D-E909DF7F53C9")
-protocol IPXCOMSocket
+protocol ISMS
{
interface:
interface_method INT32 SendMessage(_Input CONST CHAR* bytes, _Input SIZE_T bytes_size);
diff --git a/dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm b/dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm
index 847c609e..89cb4078 100644
--- a/dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm
+++ b/dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm
@@ -267,7 +267,7 @@ hal_switch_to_user_code:
mov rbx, 0x28
mov es, rbx
- mov rsp, [hal_user_code_stack_end]
+ mov rsp, hal_user_code_stack_end
mov rcx, hal_user_code_start
mov r11, 0x0202
@@ -275,9 +275,14 @@ hal_switch_to_user_code:
o64 sysret
hal_user_code_start:
-L0:
+ hlt
nop
jmp $
+hal_user_code_end:
+
+section .data
+
+hal_user_code_sz: dq hal_user_code_end - hal_user_code_start
section .bss
diff --git a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
index f20ffcee..f5f36b27 100644
--- a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
+++ b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
@@ -50,7 +50,7 @@ mp_do_context_switch:
;; Swap registers, since it's the other way around.
mov rcx, r12 ;; code ptr
- mov rsp, [r11] ;; stack ptr
+ mov rsp, r11 ;; stack ptr
mov r11, 0x0202
;; rcx and rdx already set.
diff --git a/dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx b/dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx
index 4e1b500c..82eea45e 100644
--- a/dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalPageAlloc.cxx
@@ -135,5 +135,23 @@ namespace Kernel
// Now allocate the page.
return hal_try_alloc_new_page(rw, user, size);
}
+
+ auto hal_free_page(VoidPtr page_ptr) -> Bool
+ {
+ if (!page_ptr)
+ return false;
+
+ Detail::VIRTUAL_MEMORY_HEADER* result = reinterpret_cast<Detail::VIRTUAL_MEMORY_HEADER*>((UIntPtr)page_ptr - sizeof(Detail::VIRTUAL_MEMORY_HEADER));
+
+ if (result->Magic != cVMHMagic)
+ return false;
+
+ if (result->Present != true)
+ return true;
+
+ result->Present = false;
+
+ return true;
+ }
} // namespace HAL
} // namespace Kernel
diff --git a/dev/ZKA/HALKit/AMD64/HalPageAlloc.hxx b/dev/ZKA/HALKit/AMD64/HalPageAlloc.hxx
index 30cb7911..38666e7e 100644
--- a/dev/ZKA/HALKit/AMD64/HalPageAlloc.hxx
+++ b/dev/ZKA/HALKit/AMD64/HalPageAlloc.hxx
@@ -82,7 +82,8 @@ namespace Kernel::HAL
PageTable64 ALIGN(kPTEAlign) Pte[kPTEMax];
};
- VoidPtr hal_alloc_page(Boolean rw, Boolean user, SizeT size);
+ auto hal_alloc_page(Boolean rw, Boolean user, SizeT size) -> VoidPtr;
+ auto hal_free_page(VoidPtr page_ptr) -> Bool;
} // namespace Kernel::HAL
namespace Kernel
diff --git a/dev/ZKA/NetworkKit/IPC.hxx b/dev/ZKA/NetworkKit/IPC.hxx
index 069a2c66..d71248cf 100644
--- a/dev/ZKA/NetworkKit/IPC.hxx
+++ b/dev/ZKA/NetworkKit/IPC.hxx
@@ -19,12 +19,12 @@
/// @brief IPC EP protocol.
/// IA separator.
-#define cIPCEPRemoteSeparator ":"
+#define cXPCOMRemoteSeparator ":"
/// Interchange address, consists of PID:TEAM.
-#define cIPCEPRemoteInvalid "00:00"
+#define cXPCOMRemoteInvalid "00:00"
-#define cIPCEPHeaderMagic (0x4950434)
+#define cXPCOMHeaderMagic (0x4950434)
namespace Kernel
{
@@ -61,7 +61,7 @@ namespace Kernel
eIPCEPMixedEndian = 2,
};
- constexpr auto cIPCEPMsgSize = 6094U;
+ constexpr auto cXPCOMMsgSize = 6094U;
/// @brief IPC connection header, message cannot be greater than 6K.
typedef struct IPC_MESSAGE_STRUCT final
@@ -74,7 +74,7 @@ namespace Kernel
UInt32 IpcCRC32;
UInt32 IpcMsg;
UInt32 IpcMsgSz;
- UInt8 IpcData[cIPCEPMsgSize];
+ UInt8 IpcData[cXPCOMMsgSize];
} PACKED IPC_MESSAGE_STRUCT;
/// @brief Sanitize packet function
diff --git a/dev/ZKA/Sources/Heap.cxx b/dev/ZKA/Sources/Heap.cxx
index a89ed584..0146bd55 100644
--- a/dev/ZKA/Sources/Heap.cxx
+++ b/dev/ZKA/Sources/Heap.cxx
@@ -34,6 +34,8 @@ namespace Kernel
UInt32 fMagic;
///! @brief Boolean value which tells if the heap is allocated.
Boolean fPresent;
+ /// @brief Is this valued owned by the user?
+ Boolean fUserOwned;
///! @brief 32-bit CRC checksum.
UInt32 fCRC32;
/// @brief 64-bit pointer size.
@@ -108,6 +110,8 @@ namespace Kernel
heap_info_ptr->fCRC32 = 0U; // dont fill it for now.
heap_info_ptr->fTargetPtr = wrapper.VirtualAddress() + sizeof(Detail::HEAP_INFORMATION_BLOCK);
heap_info_ptr->fPagePtr = 0UL;
+ heap_info_ptr->fUserOwned = user;
+ heap_info_ptr->fPresent = true;
++kHeapCount;
@@ -176,7 +180,10 @@ namespace Kernel
ke_calculate_crc32((Char*)heapInfoBlk->fTargetPtr,
heapInfoBlk->fTargetPtrSize))
{
- ke_stop(RUNTIME_CHECK_POINTER);
+ if (!heapInfoBlk->fUserOwned)
+ {
+ ke_stop(RUNTIME_CHECK_POINTER);
+ }
}
}
diff --git a/dev/ZKA/Sources/Network/IPC.cxx b/dev/ZKA/Sources/Network/IPC.cxx
index e5926c7f..e60742ca 100644
--- a/dev/ZKA/Sources/Network/IPC.cxx
+++ b/dev/ZKA/Sources/Network/IPC.cxx
@@ -41,12 +41,12 @@ Bool ipc_int_sanitize_packet(IPC_MESSAGE_STRUCT* pckt)
}
if (pckt->IpcFrom == pckt->IpcTo ||
- pckt->IpcPacketSize > cIPCEPMsgSize)
+ pckt->IpcPacketSize > cXPCOMMsgSize)
{
goto ipc_check_failed;
}
- return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cIPCEPHeaderMagic;
+ return pckt->IpcPacketSize > 1 && pckt->IpcHeaderMagic == cXPCOMHeaderMagic;
ipc_check_failed:
ErrLocal() = kErrorIPC;
@@ -92,7 +92,7 @@ namespace Kernel
if (*pckt_in)
{
- (*pckt_in)->IpcHeaderMagic = cIPCEPHeaderMagic;
+ (*pckt_in)->IpcHeaderMagic = cXPCOMHeaderMagic;
auto endian = DEDUCE_ENDIAN((*pckt_in), ((Char*)(*pckt_in))[0]);
diff --git a/dev/ZKA/Sources/PageManager.cxx b/dev/ZKA/Sources/PageManager.cxx
index 549415f3..d14130ff 100644
--- a/dev/ZKA/Sources/PageManager.cxx
+++ b/dev/ZKA/Sources/PageManager.cxx
@@ -82,8 +82,9 @@ namespace Kernel
{
if (wrapper)
{
- if (!Detail::page_disable(wrapper->VirtualAddress()))
+ if (!Kernel::HAL::hal_free_page((VoidPtr)wrapper->VirtualAddress()))
return false;
+
return true;
}