summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-26 05:16:48 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-26 05:16:48 +0100
commit1cd930c0c72f215101300dfcc5860800a474362d (patch)
tree78b3a29c8d9936baaa78b628e0862eb6546c56d8
parent4bac72356c29f6f92c0d0df40e1aef09a4216d56 (diff)
Kernel: Adding IPC support.
Kernel: Adding better framebuffer support. Kernel: Expose part of CFKit' URL API. System.Core: Rename most of API types to their <Prefix> with Ref at the end. System.Core: Add API to Window.hxx System.Driver: Add Driver SDK. Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
-rw-r--r--.vscode/c_cpp_properties.json47
-rw-r--r--Private/CFKit/IPCEndpoint.hxx27
-rw-r--r--Private/CFKit/URL.hpp9
-rw-r--r--Private/KernelKit/Framebuffer.hpp6
-rw-r--r--Private/Source/URL.cxx6
-rw-r--r--Public/Developer/System.Core/Headers/File.hxx47
-rw-r--r--Public/Developer/System.Core/Headers/Heap.hxx8
-rw-r--r--Public/Developer/System.Core/Headers/Window/Image.hxx1
-rw-r--r--Public/Developer/System.Core/Headers/Window/Menu.hxx1
-rw-r--r--Public/Developer/System.Core/Headers/Window/Rsrc.hxx1
-rw-r--r--Public/Developer/System.Core/Headers/Window/TrueType.hxx2
-rw-r--r--Public/Developer/System.Core/Headers/Window/Window.hxx78
-rw-r--r--Public/Developer/System.Core/Sources/Heap.cxx6
-rw-r--r--Public/Developer/System.Driver/.gitkeep0
14 files changed, 171 insertions, 68 deletions
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
index 9c963904..9e33fb2b 100644
--- a/.vscode/c_cpp_properties.json
+++ b/.vscode/c_cpp_properties.json
@@ -1,19 +1,18 @@
{
"configurations": [
{
- "name": "HCore (Macintosh MinGW)",
+ "name": "MicroKernel (Macintosh MinGW)",
"includePath": [
"${workspaceFolder}/Private/**",
"${workspaceFolder}/Private/NewBoot/**",
- "${workspaceFolder}/SDK/Kits/**"
+ "${workspaceFolder}/Public/Developer/**"
],
"defines": [
"__HCORE__",
"__KERNEL__",
"Z_PREFIX",
"__HAVE_HCORE_APIS__",
- "__FSKIT_NEWFS__",
- "kBootKrnlSections"
+ "__FSKIT_NEWFS__"
],
"cStandard": "c17",
"cppStandard": "c++20",
@@ -21,45 +20,33 @@
"intelliSenseMode": "gcc-x64"
},
{
- "name": "HCore (Windows MinGW)",
+ "name": "AppDev ",
"includePath": [
- "${workspaceFolder}/Private/**",
- "${workspaceFolder}/Private/NewBoot/**",
- "${workspaceFolder}/Public/SDK/**"
- ],
- "defines": [
- "__HCORE__",
- "__KERNEL__",
- "Z_PREFIX",
- "__HAVE_HCORE_APIS__",
- "__FSKIT_NEWFS__",
- "kBootKrnlSections"
+ "${workspaceFolder}/Public/Developer/**"
],
+ "defines": [],
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "gcc-x64"
},
{
- "name": "HCore Tools (Mac)",
+ "name": "MicroKernel (Windows)",
"includePath": [
- "${workspaceFolder}/Private/Tools/**"
+ "${workspaceFolder}/Private/**",
+ "${workspaceFolder}/Private/NewBoot/**",
+ "${workspaceFolder}/Public/Developer/**"
],
- "defines": [],
- "cStandard": "c17",
- "cppStandard": "c++20",
- "compilerPath": "/usr/bin/gcc",
- "intelliSenseMode": "macos-gcc-arm64"
- },
- {
- "name": "HCore Tools (Windows MinGW)",
- "includePath": [
- "${workspaceFolder}/Private/Tools/**"
+ "defines": [
+ "__HCORE__",
+ "__KERNEL__",
+ "Z_PREFIX",
+ "__HAVE_HCORE_APIS__",
+ "__FSKIT_NEWFS__"
],
- "defines": [],
"cStandard": "c17",
"cppStandard": "c++20",
"compilerPath": "C:/cygwin64/bin/x86_64-w64-mingw32-gcc.exe",
- "intelliSenseMode": "windows-gcc-x64"
+ "intelliSenseMode": "gcc-x64"
}
],
"version": 4
diff --git a/Private/CFKit/IPCEndpoint.hxx b/Private/CFKit/IPCEndpoint.hxx
new file mode 100644
index 00000000..7f6f3f22
--- /dev/null
+++ b/Private/CFKit/IPCEndpoint.hxx
@@ -0,0 +1,27 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#ifndef _INC_IPC_ENDPOINT_HXX_
+#define _INC_IPC_ENDPOINT_HXX_
+
+#include <NewKit/Defines.hpp>
+#include <NewKit/String.hpp>
+
+/// @brief Includes macros and utilities to make an IPC connection.
+
+/// IA separator.
+#define kRemoteSeparator "."
+
+/// Interchange address, consists of domain+namespace.
+#define kRemoteInvalid "00.00.00.00:00000000"
+#define kRemoteMaxLen 21
+
+namespace HCore {
+ typedef UIntPtr ipc_method_type;
+ typedef Char ipc_remote_type[kRemoteMaxLen];
+} // namespace HCore
+
+#endif // _INC_IPC_ENDPOINT_HXX_ \ No newline at end of file
diff --git a/Private/CFKit/URL.hpp b/Private/CFKit/URL.hpp
index 20375c53..eb8f674f 100644
--- a/Private/CFKit/URL.hpp
+++ b/Private/CFKit/URL.hpp
@@ -4,8 +4,8 @@
------------------------------------------- */
-#ifndef _INC_URL_HPP__
-#define _INC_URL_HPP__
+#ifndef _INC_URL_HPP_
+#define _INC_URL_HPP_
#include <NewKit/Defines.hpp>
#include <NewKit/String.hpp>
@@ -24,6 +24,9 @@ class Url final {
Ref<StringView> m_urlView;
};
+ErrorOr<StringView> url_extract_location(const char *url);
+ErrorOr<StringView> url_extract_protocol(const char *url);
} // namespace HCore
-#endif /* ifndef _INC_URL_HPP__ */
+
+#endif /* ifndef _INC_URL_HPP_ */
diff --git a/Private/KernelKit/Framebuffer.hpp b/Private/KernelKit/Framebuffer.hpp
index 0dfeacef..397f62d0 100644
--- a/Private/KernelKit/Framebuffer.hpp
+++ b/Private/KernelKit/Framebuffer.hpp
@@ -67,18 +67,18 @@ class Framebuffer final {
};
/***********************************************************************************/
-/// Framebuffer utils.
+/// Color utils.
/***********************************************************************************/
const UInt32 kRgbRed = 0x000000FF;
const UInt32 kRgbGreen = 0x0000FF00;
const UInt32 kRgbBlue = 0x00FF0000;
const UInt32 kRgbBlack = 0x00000000;
-const UInt32 kRgbWhite = 0x00FFFFFF;
+const UInt32 kRgbWhite = 0xFFFFFFFF;
} // namespace HCore
/***********************************************************************************/
-/// Framebuffer macros.
+/// Color macros.
/***********************************************************************************/
#define RGB(R, G, B) (HCore::UInt32)(0x##R##G##B)
diff --git a/Private/Source/URL.cxx b/Private/Source/URL.cxx
index 121003a2..fc515a03 100644
--- a/Private/Source/URL.cxx
+++ b/Private/Source/URL.cxx
@@ -20,14 +20,14 @@ constexpr const char *kURLProtocols[] = {
"http", // http without the secure
"file", // filesystem protocol
"ftp", // file transfer protocol
- "sysconf", // system settings
+ "sysconf", // system config
};
constexpr const int kUrlOutSz = 3; //! such as: ://
constexpr const int kProtosCount = 5;
constexpr const int kRangeSz = 4096;
-static ErrorOr<StringView> url_extract_location(const char *url) {
+ErrorOr<StringView> url_extract_location(const char *url) {
if (!url || *url == 0 || rt_string_len(url, kRangeSz) > kRangeSz)
return ErrorOr<StringView>{-1};
@@ -54,7 +54,7 @@ static ErrorOr<StringView> url_extract_location(const char *url) {
return ErrorOr<StringView>(view);
}
-static ErrorOr<StringView> url_extract_protocol(const char *url) {
+ErrorOr<StringView> url_extract_protocol(const char *url) {
if (!url || *url == 0 || rt_string_len(url, kRangeSz) > kRangeSz)
return ErrorOr<StringView>{-1};
diff --git a/Public/Developer/System.Core/Headers/File.hxx b/Public/Developer/System.Core/Headers/File.hxx
index 06c2a22e..f76dbb60 100644
--- a/Public/Developer/System.Core/Headers/File.hxx
+++ b/Public/Developer/System.Core/Headers/File.hxx
@@ -9,13 +9,13 @@
#include <System.Core/Headers/Defines.hxx>
+#define kFileOpenInterface 10
+#define kFileAliasInterface 11
+
namespace System {
class FileInterface;
class DirectoryInterface;
-typedef IntPtrType SymlinkType;
-typedef IntPtrType FileType;
-typedef IntPtrType DirectoryType;
typedef IntPtrType FSRef;
enum {
@@ -31,13 +31,17 @@ enum {
class FileInterface final {
public:
explicit FileInterface(const char *path) {
- mHandle = kApplicationObject->Invoke(kApplicationObject, kProcessCallOpenHandle,
- 0, path);
+ CA_MUST_PASS(path);
+
+ mHandle = kApplicationObject->Invoke(
+ kApplicationObject, kProcessCallOpenHandle, kFileOpenInterface, path);
}
~FileInterface() {
- kApplicationObject->Invoke(kApplicationObject, kProcessCallCloseHandle, 0,
- mHandle);
+ CA_MUST_PASS(kApplicationObject);
+
+ kApplicationObject->Invoke(kApplicationObject, kProcessCallCloseHandle,
+ kFileOpenInterface, mHandle);
}
public:
@@ -45,17 +49,19 @@ class FileInterface final {
public:
PtrVoidType Read(UIntPtrType off, SizeType sz) {
- return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle, 2,
- off, sz);
+ return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle,
+ 2, off, sz);
}
+
PtrVoidType Read(SizeType sz) {
- return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle, 3,
- sz);
+ return (PtrVoidType)kApplicationObject->Invoke(kApplicationObject, mHandle,
+ 3, sz);
}
void Write(PtrVoidType buf, UIntPtrType off, SizeType sz) {
kApplicationObject->Invoke(kApplicationObject, mHandle, 4, buf, off, sz);
}
+
void Write(PtrVoidType buf, SizeType sz) {
kApplicationObject->Invoke(kApplicationObject, mHandle, 5, buf, sz);
}
@@ -63,14 +69,21 @@ class FileInterface final {
void Seek(UIntPtrType off) {
kApplicationObject->Invoke(kApplicationObject, mHandle, 5);
}
+
void Rewind() { kApplicationObject->Invoke(kApplicationObject, mHandle, 6); }
public:
- const char *MIME();
- void MIME(const char *mime);
+ const char *MIME() {
+ return (const char *)kApplicationObject->Invoke(kApplicationObject, mHandle,
+ 7);
+ }
+
+ void MIME(const char *mime) {
+ kApplicationObject->Invoke(kApplicationObject, mHandle, 8, mime);
+ }
private:
- FileType mHandle;
+ FSRef mHandle;
};
typedef FileInterface *FilePtr;
@@ -93,12 +106,12 @@ class FileException : public SystemException {
const char *mReason{"System.Core: FileException: Catastrophic failure!"};
};
-inline IntPtrType MakeSymlink(const char *from, const char *outputWhere) {
+inline IntPtrType FSMakeAlias(const char *from, const char *outputWhere) {
CA_MUST_PASS(from);
CA_MUST_PASS(outputWhere);
- return kApplicationObject->Invoke(kApplicationObject, kProcessCallOpenHandle, 1,
- from);
+ return kApplicationObject->Invoke(kApplicationObject, kProcessCallOpenHandle,
+ kFileAliasInterface, from);
}
} // namespace System
diff --git a/Public/Developer/System.Core/Headers/Heap.hxx b/Public/Developer/System.Core/Headers/Heap.hxx
index c134ca4e..8fea34d4 100644
--- a/Public/Developer/System.Core/Headers/Heap.hxx
+++ b/Public/Developer/System.Core/Headers/Heap.hxx
@@ -12,7 +12,7 @@ namespace System {
class HeapException;
class HeapInterface;
-typedef PtrVoidType PtrHeapType;
+typedef PtrVoidType HeapRef;
enum {
kHeapExpandable = 2,
@@ -36,9 +36,9 @@ class HeapInterface final {
static HeapInterface *Shared() noexcept;
public:
- void Delete(PtrHeapType me) noexcept;
- SizeType Size(PtrHeapType me) noexcept;
- PtrHeapType New(const SizeType &sz,
+ void Delete(HeapRef me) noexcept;
+ SizeType Size(HeapRef me) noexcept;
+ HeapRef New(const SizeType &sz,
const DWordType flags = kHeapNoFlags);
};
diff --git a/Public/Developer/System.Core/Headers/Window/Image.hxx b/Public/Developer/System.Core/Headers/Window/Image.hxx
index 2a02b434..3e445532 100644
--- a/Public/Developer/System.Core/Headers/Window/Image.hxx
+++ b/Public/Developer/System.Core/Headers/Window/Image.hxx
@@ -6,3 +6,4 @@
#pragma once
+#include <System.Core/Headers/Window/Window.hxx>
diff --git a/Public/Developer/System.Core/Headers/Window/Menu.hxx b/Public/Developer/System.Core/Headers/Window/Menu.hxx
index 2a02b434..3e445532 100644
--- a/Public/Developer/System.Core/Headers/Window/Menu.hxx
+++ b/Public/Developer/System.Core/Headers/Window/Menu.hxx
@@ -6,3 +6,4 @@
#pragma once
+#include <System.Core/Headers/Window/Window.hxx>
diff --git a/Public/Developer/System.Core/Headers/Window/Rsrc.hxx b/Public/Developer/System.Core/Headers/Window/Rsrc.hxx
index 2a02b434..3e445532 100644
--- a/Public/Developer/System.Core/Headers/Window/Rsrc.hxx
+++ b/Public/Developer/System.Core/Headers/Window/Rsrc.hxx
@@ -6,3 +6,4 @@
#pragma once
+#include <System.Core/Headers/Window/Window.hxx>
diff --git a/Public/Developer/System.Core/Headers/Window/TrueType.hxx b/Public/Developer/System.Core/Headers/Window/TrueType.hxx
index 62ed1255..3e445532 100644
--- a/Public/Developer/System.Core/Headers/Window/TrueType.hxx
+++ b/Public/Developer/System.Core/Headers/Window/TrueType.hxx
@@ -5,3 +5,5 @@
------------------------------------------- */
#pragma once
+
+#include <System.Core/Headers/Window/Window.hxx>
diff --git a/Public/Developer/System.Core/Headers/Window/Window.hxx b/Public/Developer/System.Core/Headers/Window/Window.hxx
index 1a8c6cf6..5eb1b3ce 100644
--- a/Public/Developer/System.Core/Headers/Window/Window.hxx
+++ b/Public/Developer/System.Core/Headers/Window/Window.hxx
@@ -9,15 +9,15 @@
#include <System.Core/Headers/Defines.hxx>
/// @file Window.hxx
-/// @brief Tracker window manager.
+/// @brief Tracker window protocol.
/// @author Amlal El Mahrouss.
typedef float PositionType;
/// @brief A point, can represent the size, position of a window.
-typedef struct _Point {
+typedef struct _GraphicsPoint {
PositionType X, Y;
-} Point;
+} GraphicsPoint;
/// @brief Tracker Graphics port.
typedef struct _GraphicsPort {
@@ -29,10 +29,78 @@ typedef struct _GraphicsPort {
BooleanType windowMoving;
BooleanType windowDisableClose;
BooleanType windowDisableMinimize;
- Point windowPosition;
- Point windowSize;
+ GraphicsPoint windowPosition;
+ GraphicsPoint windowSize;
BooleanType windowInvalidate;
DWordType windowClearColor;
WordType menuPort;
WordType parentPort;
} GraphicsPort;
+
+typedef UInt32Type ColorRef;
+
+/***********************************************************************************/
+/// Color utils.
+/***********************************************************************************/
+
+const ColorRef kRgbRed = 0x000000FF;
+const ColorRef kRgbGreen = 0x0000FF00;
+const ColorRef kRgbBlue = 0x00FF0000;
+const ColorRef kRgbBlack = 0x00000000;
+const ColorRef kRgbWhite = 0xFFFFFFFF;
+
+/***********************************************************************************/
+/// Color macro.
+/***********************************************************************************/
+
+#define RGB32(R, G, B) (ColorRef)(0x##R##G##B)
+
+#define kGraphicsKindWindow 0
+#define kGraphicsKindDialog 1
+#define kGraphicsKindMenu 2
+#define kGraphicsKindButton 3
+#define kGraphicsKindLabel 4
+#define kGraphicsKindDropdown 5
+#define kGraphicsKindIcon 6
+#define kGraphicsKindRadio 7
+#define kGraphicsKindCheck 7
+
+typedef QWordType ControlRef;
+
+/// @brief Creates a new control
+/// @param id the control rsrc fork.
+/// @return
+CA_EXTERN_C ControlRef CreateControl(const DWordType id);
+
+/// @brief Releases the control
+/// @param id the control ref.
+/// @return
+CA_EXTERN_C VoidType ReleaseControl(const ControlRef id);
+
+CA_EXTERN_C BooleanType MoveControl(const ControlRef id, GraphicsPoint where);
+
+CA_EXTERN_C BooleanType EnableControl(const ControlRef id, BooleanType visible);
+
+CA_EXTERN_C BooleanType VisibleControl(const ControlRef id, BooleanType visible);
+
+/// @brief Creates a new window.
+/// @param name the window name
+/// @param rsrcId the window fork rsrc id.
+/// @return the window graphics port.
+CA_EXTERN_C GraphicsPort* CreateWindow(const char* name, const DWordType rsrcId);
+
+/// @brief Creates a new menu
+/// @param name the menu's name
+/// @param rsrcId the menu fork rsrc id.
+/// @return the menu graphics port.
+CA_EXTERN_C GraphicsPort* CreateMenu(const char* name, const DWordType rsrcId);
+
+/// @brief Releases the window.
+/// @param port the window port.
+/// @return void
+CA_EXTERN_C VoidType ReleaseWindow(GraphicsPort* port);
+
+/// @brief Releases the menu
+/// @param port the menu port.
+/// @return void
+CA_EXTERN_C VoidType ReleaseMenu(GraphicsPort* port);
diff --git a/Public/Developer/System.Core/Sources/Heap.cxx b/Public/Developer/System.Core/Sources/Heap.cxx
index 18106f41..370693cc 100644
--- a/Public/Developer/System.Core/Sources/Heap.cxx
+++ b/Public/Developer/System.Core/Sources/Heap.cxx
@@ -65,17 +65,17 @@ HeapInterface::HeapInterface() {
HeapInterface::~HeapInterface() { delete this; }
-void HeapInterface::Delete(PtrHeapType me) noexcept {
+void HeapInterface::Delete(HeapRef me) noexcept {
CA_MUST_PASS(me);
HcFreeProcessHeap(kApplicationObject, me);
}
-SizeType HeapInterface::Size(PtrHeapType me) noexcept {
+SizeType HeapInterface::Size(HeapRef me) noexcept {
CA_MUST_PASS(me);
return HcProcessHeapSize(kApplicationObject, me);
}
-PtrHeapType HeapInterface::New(const SizeType& sz, const DWordType flags) {
+HeapRef HeapInterface::New(const SizeType& sz, const DWordType flags) {
SizeType _sz = sz;
if (!_sz) ++_sz;
diff --git a/Public/Developer/System.Driver/.gitkeep b/Public/Developer/System.Driver/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Public/Developer/System.Driver/.gitkeep