summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-04-05 21:40:26 +0200
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-04-05 21:40:34 +0200
commit5152c2282a1a680a272322f0bd3275fdf43e1530 (patch)
tree9cb1272d1eb8e34212148408aba0bc2bc45c58d4
parent21fe8d0b7d48e92ba0d45c084bf868c94bb67cd7 (diff)
WiP: Bump.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
-rw-r--r--Private/Source/DriveManager.cxx3
-rw-r--r--Private/Source/KernelCheck.cxx2
-rw-r--r--Private/Source/SMPManager.cxx7
-rw-r--r--Private/Source/ThreadLocalStorage.cxx2
-rw-r--r--Private/Source/Timer.cxx3
-rw-r--r--Public/Developer/FragLib/Sources/RuntimeFrag.c (renamed from Public/Developer/SystemLib/Sources/ApplicationStart.c)12
-rw-r--r--Public/Developer/SystemLib/AMD64/CoreAssembly.s10
-rw-r--r--Public/Developer/SystemLib/Headers/Defines.h6
-rw-r--r--Public/Developer/SystemLib/Headers/Dialog.h26
-rw-r--r--Public/Developer/SystemLib/Headers/Draw.h20
-rw-r--r--Public/Developer/SystemLib/Headers/TrueType.h10
-rw-r--r--Public/Developer/SystemLib/Headers/Window.h31
-rw-r--r--Public/Developer/SystemLib/PowerPC/CoreAssembly.s25
-rw-r--r--Public/Developer/SystemLib/Sources/Application.c4
-rw-r--r--Public/Developer/SystemLib/Sources/Window.c28
15 files changed, 127 insertions, 62 deletions
diff --git a/Private/Source/DriveManager.cxx b/Private/Source/DriveManager.cxx
index f79fcdf5..f9a07c66 100644
--- a/Private/Source/DriveManager.cxx
+++ b/Private/Source/DriveManager.cxx
@@ -8,6 +8,9 @@
#include <KernelKit/DriveManager.hxx>
#include <Builtins/ATA/Defines.hxx>
+/// @file DriveManager.cxx
+/// @brief Kernel drive manager.
+
namespace NewOS {
static UInt16 kATAIO = 0U;
static UInt8 kATAMaster = 0U;
diff --git a/Private/Source/KernelCheck.cxx b/Private/Source/KernelCheck.cxx
index 2c5431e8..5f617f06 100644
--- a/Private/Source/KernelCheck.cxx
+++ b/Private/Source/KernelCheck.cxx
@@ -62,7 +62,7 @@ void ke_stop(const NewOS::Int &id) {
}
case RUNTIME_CHECK_INVALID_PRIVILEGE: {
kcout << "*** CAUSE: RUNTIME_CHECK_INVALID_PRIVILEGE *** \r\n";
- kcout << "*** WHAT: RING-0 POLICY VIOLATION. *** \r\n";
+ kcout << "*** WHAT: HYPERVISOR POLICY VIOLATION. *** \r\n";
break;
case RUNTIME_CHECK_UNEXCPECTED: {
kcout << "*** CAUSE: RUNTIME_CHECK_UNEXCPECTED *** \r\n";
diff --git a/Private/Source/SMPManager.cxx b/Private/Source/SMPManager.cxx
index 913bb44d..18625cc5 100644
--- a/Private/Source/SMPManager.cxx
+++ b/Private/Source/SMPManager.cxx
@@ -10,6 +10,7 @@
///! BUGS: 0
+///! @file SMPManager.cxx
///! @brief This file handles multi processing in NewOS.
///! @brief Multi processing is needed for multi-tasking operations.
@@ -37,7 +38,7 @@ bool HardwareThread::IsBusy() noexcept { return m_Busy; }
/// @brief Get processor stack frame.
-HAL::StackFrame* HardwareThread::StackFrame() noexcept {
+HAL::StackFramePtr HardwareThread::StackFrame() noexcept {
MUST_PASS(m_Stack);
return m_Stack;
}
@@ -59,7 +60,7 @@ void HardwareThread::Wake(const bool wakeup) noexcept {
extern bool rt_check_stack(HAL::StackFramePtr stackPtr);
-bool HardwareThread::Switch(HAL::StackFrame* stack) {
+bool HardwareThread::Switch(HAL::StackFramePtr stack) {
if (!rt_check_stack(stack)) return false;
m_Stack = stack;
@@ -96,7 +97,7 @@ HAL::StackFramePtr SMPManager::GetStackFrame() noexcept {
}
/// @brief Finds and switch to a free core.
-bool SMPManager::Switch(HAL::StackFrame* stack) {
+bool SMPManager::Switch(HAL::StackFramePtr stack) {
if (stack == nullptr) return false;
for (SizeT idx = 0; idx < kMaxHarts; ++idx) {
diff --git a/Private/Source/ThreadLocalStorage.cxx b/Private/Source/ThreadLocalStorage.cxx
index 3d0a8cdb..2bc0e298 100644
--- a/Private/Source/ThreadLocalStorage.cxx
+++ b/Private/Source/ThreadLocalStorage.cxx
@@ -10,7 +10,7 @@
#include <KernelKit/ProcessScheduler.hpp>
#include <KernelKit/ThreadLocalStorage.hxx>
-/// bugs 0
+///! BUGS: 0
/***********************************************************************************/
/// @file ThreadLocalStorage.cxx
diff --git a/Private/Source/Timer.cxx b/Private/Source/Timer.cxx
index a35cc06f..fbfb768c 100644
--- a/Private/Source/Timer.cxx
+++ b/Private/Source/Timer.cxx
@@ -6,7 +6,8 @@
#include <KernelKit/Timer.hpp>
-// bugs = 0
+///! BUGS: 0
+///! @file Timer.cxx
using namespace NewOS;
diff --git a/Public/Developer/SystemLib/Sources/ApplicationStart.c b/Public/Developer/FragLib/Sources/RuntimeFrag.c
index 0960388e..f9e7c442 100644
--- a/Public/Developer/SystemLib/Sources/ApplicationStart.c
+++ b/Public/Developer/FragLib/Sources/RuntimeFrag.c
@@ -6,9 +6,17 @@
#include <Headers/Defines.h>
-/// @brief Inits the system library.
-/// @return if it was succesful or not.
+/// @brief Main application entrypoint.
+/// @param
+/// @return
+CA_EXTERN_C VoidType AppMain(VoidType);
+
+/// @brief Pre-entrypoint intiialization.
+/// @param
+/// @return
CA_EXTERN_C VoidType __start(VoidType) {
kSharedApplication = RtGetApp();
CA_MUST_PASS(kSharedApplication);
+
+ AppMain();
}
diff --git a/Public/Developer/SystemLib/AMD64/CoreAssembly.s b/Public/Developer/SystemLib/AMD64/CoreAssembly.s
index 1d361621..5c398e94 100644
--- a/Public/Developer/SystemLib/AMD64/CoreAssembly.s
+++ b/Public/Developer/SystemLib/AMD64/CoreAssembly.s
@@ -1,6 +1,10 @@
-/** ===========================================
- (C) Mahrouss Logic
- ===========================================*/
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+ Purpose: AMD64 low level I/O
+
+------------------------------------------- */
.section .text
diff --git a/Public/Developer/SystemLib/Headers/Defines.h b/Public/Developer/SystemLib/Headers/Defines.h
index d3b6b793..7bd40c76 100644
--- a/Public/Developer/SystemLib/Headers/Defines.h
+++ b/Public/Developer/SystemLib/Headers/Defines.h
@@ -51,6 +51,12 @@ typedef CharacterTypeUTF8* PtrCharacterType;
typedef void* PtrVoidType;
typedef void VoidType;
+#ifdef __SINGLE_PRECISION__
+typedef float PositionType;
+#else
+typedef double PositionType;
+#endif
+
typedef __UINTPTR_TYPE__ UIntPtrType;
typedef __INTPTR_TYPE__ IntPtrType;
typedef __UINT64_TYPE__ UInt64Type;
diff --git a/Public/Developer/SystemLib/Headers/Dialog.h b/Public/Developer/SystemLib/Headers/Dialog.h
index b2bc93a1..0c0e4dbc 100644
--- a/Public/Developer/SystemLib/Headers/Dialog.h
+++ b/Public/Developer/SystemLib/Headers/Dialog.h
@@ -8,6 +8,32 @@
#include <Headers/Window.h>
+struct _DialogPort;
+struct _DialogPoint;
+
+/// @brief Dialog procedure type.
+typedef VoidType(*WmDialogProc)(struct _DialogPort* port, UInt32Type msg, UIntPtrType pParam, UIntPtrType iParam);
+
+/// @brief A point, can represent the size, position of a window.
+typedef struct _DialogPoint {
+ PositionType X, Y;
+} DialogPoint;
+
+typedef struct _DialogPort {
+ WordType dlgPort;
+ WordType dlgKind;
+ BooleanType dlgVisible;
+ BooleanType dlgMoving;
+ DialogPoint dlgPosition;
+ WmDialogProc dlgProc;
+ struct _WindowPort* parentPort;
+} DialogPort;
+
+/// @brief Creates a new dialog from a rsrc fork id.
+/// @param rsrcId the resource id.
+/// @return the dialog port.
+CA_EXTERN_C DialogPort* DlgCreateFromRsrc(QWordType rsrcId);
+
/// @brief Shows an message box according to format.
/// @param title the message box title
/// @param format the format
diff --git a/Public/Developer/SystemLib/Headers/Draw.h b/Public/Developer/SystemLib/Headers/Draw.h
new file mode 100644
index 00000000..3060db9d
--- /dev/null
+++ b/Public/Developer/SystemLib/Headers/Draw.h
@@ -0,0 +1,20 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#pragma once
+
+#include <Headers/Window.h>
+
+/*************************************************************
+ *
+ * File: Draw.h
+ * Purpose: Draw Manager API for NewOS.
+ * Date: 3/26/24
+ *
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ *************************************************************/
+
diff --git a/Public/Developer/SystemLib/Headers/TrueType.h b/Public/Developer/SystemLib/Headers/TrueType.h
index fb68298a..7f1bed86 100644
--- a/Public/Developer/SystemLib/Headers/TrueType.h
+++ b/Public/Developer/SystemLib/Headers/TrueType.h
@@ -10,7 +10,7 @@
/*************************************************************
*
- * File: TrueType.hxx
+ * File: TrueType.h
* Purpose: TrueType font implementation for NewOS.
* Date: 3/26/24
*
@@ -35,10 +35,4 @@ CA_EXTERN_C VoidType FnDisposeFont(TTFFontRef fon);
/// @return
CA_EXTERN_C PtrVoidType FnGetGlyph(TTFFontRef fon, UInt32Type utfCh);
-/// @brief Write a character to the window.
-/// @param fon the font.
-/// @param port the window port.
-/// @param pos the position of where to put the character.
-/// @return
-CA_EXTERN_C VoidType FnWriteCharacter(TTFFontRef fon, WindowPort* port, PositionType pos);
-
+/// TODO: Get font metadata. \ No newline at end of file
diff --git a/Public/Developer/SystemLib/Headers/Window.h b/Public/Developer/SystemLib/Headers/Window.h
index 1fd9e9e3..58b10d8e 100644
--- a/Public/Developer/SystemLib/Headers/Window.h
+++ b/Public/Developer/SystemLib/Headers/Window.h
@@ -10,7 +10,7 @@
/*************************************************************
*
- * File: Window.hxx
+ * File: Window.h
* Purpose: Window Manager API for NewOS.
* Date: 3/26/24
*
@@ -21,18 +21,14 @@
struct _WmPoint;
struct _WindowPort;
-#ifdef __SINGLE_PRECISION__
-typedef float PositionType;
-#else
-typedef double PositionType;
-#endif
-
struct _ControlPort;
struct _WmPoint;
-struct _WindowPort;
typedef QWordType DCRef;
+/// @brief Window procedure type.
+typedef VoidType(*WmWindowProc)(struct _WindowPort* port, UInt32Type msg, UIntPtrType pParam, UIntPtrType iParam);
+
/// @brief A point, can represent the size, position of a window.
typedef struct _WmPoint {
PositionType X, Y;
@@ -52,6 +48,7 @@ typedef struct _WindowPort {
WmPoint windowSize;
BooleanType windowInvalidate;
DWordType windowClearColor;
+ WmWindowProc windowProc;
struct _WindowPort* windowMenuPort; ///! Attached menu to it.
struct _WindowPort* windowParentPort;
} WindowPort;
@@ -63,9 +60,17 @@ typedef struct _ControlPort {
BooleanType controlVisible;
BooleanType controlMoving;
WmPoint controlPosition;
+ WmWindowProc controlProc;
WindowPort* parentPort;
} ControlPort;
+enum {
+ kWmErrIncompatible = 0x74,
+ kWmErrOutOfMemory,
+ kWmErrInvalidArg,
+ kWmErrNotImplemented,
+};
+
/// @brief Color reference.
typedef UInt32Type ColorRef;
@@ -94,6 +99,7 @@ CA_EXTERN_C const ColorRef kRgbWhite;
#define kControlKindIcon 6
#define kControlKindRadioBox 7
#define kControlKindCheckBox 8
+#define kControlKindUserDefined 9
/// @brief Creates a new control
/// @param id the control rsrc fork.
@@ -121,7 +127,7 @@ CA_EXTERN_C Int32Type WmSetControlEnabled(ControlPort* id, BooleanType enabl
/// @param id
/// @param visible
/// @return
-CA_EXTERN_C Int32Type WmMakeControlVisible(ControlPort* id, BooleanType visible);
+CA_EXTERN_C Int32Type WmSetControlVisible(ControlPort* id, BooleanType visible);
/// @brief Creates a new window.
/// @param name the window name
@@ -164,10 +170,3 @@ CA_EXTERN_C VoidType WmTranslateMessage(WindowPort* port, Int64Type msg);
/// @param id
/// @return
CA_EXTERN_C Int32Type WmDispatchMessage(WindowPort* id);
-
-enum {
- kWmErrIncompatible = 0x74,
- kWmErrOutOfMemory,
- kWmErrInvalidArg,
- kWmErrNotImplemented,
-};
diff --git a/Public/Developer/SystemLib/PowerPC/CoreAssembly.s b/Public/Developer/SystemLib/PowerPC/CoreAssembly.s
index 7fef98e3..98fbcca9 100644
--- a/Public/Developer/SystemLib/PowerPC/CoreAssembly.s
+++ b/Public/Developer/SystemLib/PowerPC/CoreAssembly.s
@@ -1,25 +1,22 @@
-/** ===========================================
- (C) Mahrouss Logic
- Purpose: PowerPC low-level routines.
- ===========================================*/
+; /* -------------------------------------------
+;
+; Copyright Mahrouss Logic
+;
+; Purpose: PowerPC low level I/O
+;
+; ------------------------------------------- */
-.section .text
-
-.globl RtGetApp
-.globl RtAssertTriggerInterrupt
-.balign 4
/* @brief Application getter */
/* @throws: ApptError: appartement error. */
-RtGetApp:
- stw 0x10, 0(3) /* sysGetProcessObject */
+export .code64 RtGetApp:
+ stw 0x10, 0(r3) /* sysGetProcessObject */
sc
blr
-RtAssertTriggerInterrupt:
- stw 0x11, 0(3) /* sysTerminateCurrentProcess */
- stw 0x3, 0(4)
+export .code64 RtAssertTriggerInterrupt:
+ stw 0x11, 0(r3) /* sysTerminateCurrentProcess */
sc
blr
diff --git a/Public/Developer/SystemLib/Sources/Application.c b/Public/Developer/SystemLib/Sources/Application.c
index f1391975..69f178af 100644
--- a/Public/Developer/SystemLib/Sources/Application.c
+++ b/Public/Developer/SystemLib/Sources/Application.c
@@ -21,5 +21,5 @@ CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) {
/// @return
CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType) {
return (CharacterTypeUTF8**)kSharedApplication->Invoke(kSharedApplication,
- kCallGetArgsPtr);
-} \ No newline at end of file
+ kCallGetArgsPtr);
+}
diff --git a/Public/Developer/SystemLib/Sources/Window.c b/Public/Developer/SystemLib/Sources/Window.c
index 2527e041..196ac537 100644
--- a/Public/Developer/SystemLib/Sources/Window.c
+++ b/Public/Developer/SystemLib/Sources/Window.c
@@ -9,6 +9,14 @@
/// invalid resource handle, they always start from 1.
#define kInvalidRsrc (0U)
+/// @brief Color refs.
+
+const ColorRef kRgbRed = 0x000000FF;
+const ColorRef kRgbGreen = 0x0000FF00;
+const ColorRef kRgbBlue = 0x00FF0000;
+const ColorRef kRgbBlack = 0x00000000;
+const ColorRef kRgbWhite = 0xFFFFFFFF;
+
/////////////////////////////////////////////////////////////////////////
CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name,
@@ -16,6 +24,9 @@ CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name,
CA_MUST_PASS(name);
CA_MUST_PASS(rsrcId != kInvalidRsrc);
+ if (!name) return NullPtr;
+ if (rsrcId == kInvalidRsrc) return NullPtr;
+
return (WindowPort*)kSharedApplication->Invoke(
kSharedApplication, kCallCreateWindow, name, rsrcId);
}
@@ -24,6 +35,7 @@ CA_EXTERN_C WindowPort* WmCreateWindow(const CharacterTypeUTF8* name,
CA_EXTERN_C VoidType WmReleaseWindow(WindowPort* winPort) {
CA_MUST_PASS(winPort);
+ if (!winPort) return;
kSharedApplication->Invoke(kSharedApplication, kCallCloseWindow, winPort);
}
@@ -35,6 +47,9 @@ CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name,
CA_MUST_PASS(name);
CA_MUST_PASS(rsrcId != kInvalidRsrc);
+ if (!name) return NullPtr;
+ if (rsrcId == kInvalidRsrc) return NullPtr;
+
return (WindowPort*)kSharedApplication->Invoke(kSharedApplication,
kCallCreateMenu, name, rsrcId);
}
@@ -44,15 +59,14 @@ CA_EXTERN_C WindowPort* WmCreateMenu(const CharacterTypeUTF8* name,
CA_EXTERN_C VoidType WmReleaseMenu(WindowPort* winPort) {
CA_MUST_PASS(winPort);
+ if (!winPort) return;
kSharedApplication->Invoke(kSharedApplication, kCallCloseMenu, winPort);
}
/////////////////////////////////////////////////////////////////////////
CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* id, WmPoint where) {
- if (!id) {
- return kWmErrInvalidArg;
- }
+ if (!id) return kWmErrInvalidArg;
id->windowPosition.X = where.X;
id->windowPosition.Y = where.Y;
@@ -60,11 +74,3 @@ CA_EXTERN_C Int32Type WmMoveWindow(WindowPort* id, WmPoint where) {
return 0;
}
-
-/// @brief Color refs.
-
-const ColorRef kRgbRed = 0x000000FF;
-const ColorRef kRgbGreen = 0x0000FF00;
-const ColorRef kRgbBlue = 0x00FF0000;
-const ColorRef kRgbBlack = 0x00000000;
-const ColorRef kRgbWhite = 0xFFFFFFFF;