summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-26 20:00:41 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-26 20:01:41 +0100
commit5ab8bb9c497f673a81da693e9aacc78210718000 (patch)
tree3ae1d5fe040c2c09e92e121436a54650b0adcd35
parent9a0c2664b0ca5634aa557b0761139cccfb0fe753 (diff)
Kernel: Implement more API calls.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
-rw-r--r--Private/Builtins/AHCI/Defines.hxx19
-rw-r--r--Private/Builtins/AHCI/Interface.hxx28
-rw-r--r--Private/Builtins/ATA/Defines.hxx2
-rw-r--r--Private/HALKit/AMD64/Storage/.gitkeep0
-rw-r--r--Private/HALKit/AMD64/Storage/AHCI.cxx18
-rw-r--r--Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s4
-rw-r--r--Public/Developer/System.Core/Headers/Defines.hxx11
-rw-r--r--Public/Developer/System.Core/Headers/Dialog.hxx7
-rw-r--r--Public/Developer/System.Core/Headers/Heap.hxx10
-rw-r--r--Public/Developer/System.Core/Headers/Thread.hxx15
-rw-r--r--Public/Developer/System.Core/Headers/TrueType.hxx12
-rw-r--r--Public/Developer/System.Core/Headers/Window.hxx4
-rw-r--r--Public/Developer/System.Core/Makefile2
-rw-r--r--Public/Developer/System.Core/Sources/CRT0.cxx2
-rw-r--r--Public/Developer/System.Core/Sources/Heap.cxx8
-rw-r--r--Public/Developer/System.Core/Sources/New+Delete.cxx10
16 files changed, 95 insertions, 57 deletions
diff --git a/Private/Builtins/AHCI/Defines.hxx b/Private/Builtins/AHCI/Defines.hxx
index c1d3c063..e1aa72ae 100644
--- a/Private/Builtins/AHCI/Defines.hxx
+++ b/Private/Builtins/AHCI/Defines.hxx
@@ -310,7 +310,24 @@ typedef struct HbaCmdTbl final {
HCore::UInt8 cfis[64]; // Command FIS
HCore::UInt8 acmd[16]; // ATAPI command, 12 or 16 bytes
HCore::UInt8 rsv[48]; // Reserved
- HbaPrdtEntry prdtEntries[1]; // Physical region descriptor table entries, 0 ~ 65535
+ struct HbaPrdtEntry prdtEntries[1]; // Physical region descriptor table entries, 0 ~ 65535
} HbaCmdTbl;
/* EOF */
+
+#ifdef __KERNEL__
+
+/// @brief Initializes an AHCI disk.
+/// @param PortsImplemented the amount of port that have been detected.
+/// @return
+HCore::Boolean drv_ahci_init(HCore::UInt16& PortsImplemented);
+
+HCore::Boolean drv_ahci_detected(HCore::Void);
+
+HCore::Void drv_ahci_read(HCore::UInt64 Lba, HCore::UInt16 IO, HCore::UInt8 Master, HCore::Char* Buf,
+ HCore::SizeT SectorSz, HCore::SizeT Size);
+
+HCore::Void drv_ahci_write(HCore::UInt64 Lba, HCore::UInt16 IO, HCore::UInt8 Master, HCore::Char* Buf,
+ HCore::SizeT SectorSz, HCore::SizeT Size);
+
+#endif // ifdef __KERNEL__
diff --git a/Private/Builtins/AHCI/Interface.hxx b/Private/Builtins/AHCI/Interface.hxx
deleted file mode 100644
index 0fef6992..00000000
--- a/Private/Builtins/AHCI/Interface.hxx
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
- File: Interface.hxx
- Purpose: AHCI Interface.
-
- Revision History:
-
- 03/17/24: Added file (amlel)
-
-------------------------------------------- */
-
-#pragma once
-
-#include <AHCI/Defines.hxx>
-#include <NewKit/Defines.hpp>
-#include <ObjectKit/ObjectKit.hxx>
-#include <HintKit/CompilerHint.hxx>
-
-#define kObjectAHCINamespace "AHCI\\"
-
-namespace HCore::Builtins {
-/// @brief Returns an AHCI handle.
-/// @param pointerAhciObject the handle to pass.
-/// @return
-inline Boolean HcGetHandleAHCI(_InOut ObjectRef* pointerAhciObject);
-} // namespace HCore::Builtins \ No newline at end of file
diff --git a/Private/Builtins/ATA/Defines.hxx b/Private/Builtins/ATA/Defines.hxx
index 01b67c42..fbb7c63c 100644
--- a/Private/Builtins/ATA/Defines.hxx
+++ b/Private/Builtins/ATA/Defines.hxx
@@ -142,4 +142,4 @@ HCore::Void drv_ata_read(HCore::UInt64 Lba, HCore::UInt16 IO, HCore::UInt8 Maste
HCore::Void drv_ata_write(HCore::UInt64 Lba, HCore::UInt16 IO, HCore::UInt8 Master, HCore::Char* Buf,
HCore::SizeT SectorSz, HCore::SizeT Size);
-#endif // ifdef __KERNEL__ \ No newline at end of file
+#endif // ifdef __KERNEL__
diff --git a/Private/HALKit/AMD64/Storage/.gitkeep b/Private/HALKit/AMD64/Storage/.gitkeep
deleted file mode 100644
index e69de29b..00000000
--- a/Private/HALKit/AMD64/Storage/.gitkeep
+++ /dev/null
diff --git a/Private/HALKit/AMD64/Storage/AHCI.cxx b/Private/HALKit/AMD64/Storage/AHCI.cxx
new file mode 100644
index 00000000..25318212
--- /dev/null
+++ b/Private/HALKit/AMD64/Storage/AHCI.cxx
@@ -0,0 +1,18 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+/**
+ * @file AHCI.cxx
+ * @author Amlal El Mahrouss (amlalelmahrouss@icloud.com)
+ * @brief AHCI driver.
+ * @version 0.1
+ * @date 2024-02-02
+ *
+ * @copyright Copyright (c) Mahrouss Logic
+ *
+ */
+
+#include <Builtins/AHCI/Defines.hxx> \ No newline at end of file
diff --git a/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s b/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s
index 3876175b..58bb1260 100644
--- a/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s
+++ b/Public/Developer/System.Core/AMD64/HCoreAssemblyRoutines.s
@@ -4,12 +4,12 @@
.section .text
-.globl HcGetAppObject
+.globl RtGetAppObject
.globl __assert_chk_fail
/* @brief Process object getter */
/* @throws: ApptError: appartement error. */
-HcGetAppObject:
+RtGetAppObject:
mov $0x10, %rcx /* sysGetProcessObject */
int $0x21
diff --git a/Public/Developer/System.Core/Headers/Defines.hxx b/Public/Developer/System.Core/Headers/Defines.hxx
index 55810d9d..9932298e 100644
--- a/Public/Developer/System.Core/Headers/Defines.hxx
+++ b/Public/Developer/System.Core/Headers/Defines.hxx
@@ -117,7 +117,7 @@ typedef CharacterTypeUTF8 BooleanType;
#define CA_CONSTEXPR
#endif // __cplusplus
-enum HcProcessCall {
+enum RtProcessCall {
kProcessCallAllocPtr = 1,
kProcessCallFreePtr,
kProcessCallSizePtr,
@@ -181,15 +181,8 @@ using StrType = CharacterTypeUTF8[N];
#endif // ifdef C++
-CA_EXTERN_C ObjectRef HcGetAppObject(VoidType);
+CA_EXTERN_C ObjectRef RtGetAppObject(VoidType);
CA_INLINE ObjectRef kApplicationObject;
typedef CharacterTypeUTF8 Str255Type[255];
-
-/// @brief Shows an message box with a formatting.
-/// @param title the message box title
-/// @param format the format
-/// @param va_list the va args, that goes along with it.
-/// @return void
-CA_EXTERN_C VoidType MsgBox(CharacterTypeUTF8* title, CharacterTypeUTF8* format, ...);
diff --git a/Public/Developer/System.Core/Headers/Dialog.hxx b/Public/Developer/System.Core/Headers/Dialog.hxx
index 0fc4e738..1cc97a6e 100644
--- a/Public/Developer/System.Core/Headers/Dialog.hxx
+++ b/Public/Developer/System.Core/Headers/Dialog.hxx
@@ -7,3 +7,10 @@
#pragma once
#include <System.Core/Headers/Window.hxx>
+
+/// @brief Shows an message box with a formatting.
+/// @param title the message box title
+/// @param format the format
+/// @param va_list the va args, that goes along with it.
+/// @return void
+CA_EXTERN_C VoidType MsgBox(CharacterTypeUTF8* title, CharacterTypeUTF8* format, ...);
diff --git a/Public/Developer/System.Core/Headers/Heap.hxx b/Public/Developer/System.Core/Headers/Heap.hxx
index 98ee5bd2..c6252c04 100644
--- a/Public/Developer/System.Core/Headers/Heap.hxx
+++ b/Public/Developer/System.Core/Headers/Heap.hxx
@@ -10,7 +10,7 @@
#define kAllocationTypes 2
-enum HcAllocationKind {
+enum RtAllocationKind {
kStandardAllocation = 0xC,
kArrayAllocation = 0xD,
};
@@ -20,13 +20,13 @@ enum HcAllocationKind {
/// @param sz
/// @param flags
/// @return
-CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectRef refObj, QWordType sz,
+CA_EXTERN_C PtrVoidType RtAllocateProcessHeap(ObjectRef refObj, QWordType sz,
DWordType flags);
/// @brief Check if pointer exists.
/// @param refObj
/// @param ptr
/// @return
-CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectRef refObj, PtrVoidType ptr);
-CA_EXTERN_C QWordType HcProcessHeapSize(ObjectRef refObj, PtrVoidType ptr);
-CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr);
+CA_EXTERN_C BooleanType RtProcessHeapExists(ObjectRef refObj, PtrVoidType ptr);
+CA_EXTERN_C QWordType RtProcessHeapSize(ObjectRef refObj, PtrVoidType ptr);
+CA_EXTERN_C VoidType RtFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr);
diff --git a/Public/Developer/System.Core/Headers/Thread.hxx b/Public/Developer/System.Core/Headers/Thread.hxx
index df803860..a441041d 100644
--- a/Public/Developer/System.Core/Headers/Thread.hxx
+++ b/Public/Developer/System.Core/Headers/Thread.hxx
@@ -13,6 +13,8 @@
#include <System.Core/Headers/Defines.hxx>
+#define kThreadErrorExit -33
+
/// @brief Thread Information Block, which holds information about the running
/// thread.
typedef QWordType ThreadRef;
@@ -20,4 +22,17 @@ typedef QWordType ThreadRef;
/// @brief Main application thread.
CA_EXTERN_C ThreadRef kMainThread;
+typedef VoidType(*ThreadEntrypointKind)(VoidType);
+
+/// @brief Creates a new thread, and runs the code.
+/// @param threadName the thread's name.
+/// @param threadStart where to start.
+/// @return
+CA_EXTERN_C ThreadRef CreateThread(const CharacterTypeUTF8* threadName, ThreadEntrypointKind threadStart);
+
+/// @brief Dispoes the thread, and exits with code kThreadErrorExit
+/// @param ref
+/// @return
+CA_EXTERN_C VoidType DisposeThread(ThreadRef ref);
+
#endif // __THREAD_API__
diff --git a/Public/Developer/System.Core/Headers/TrueType.hxx b/Public/Developer/System.Core/Headers/TrueType.hxx
index 14a85823..001d986e 100644
--- a/Public/Developer/System.Core/Headers/TrueType.hxx
+++ b/Public/Developer/System.Core/Headers/TrueType.hxx
@@ -17,3 +17,15 @@
* Copyright Mahrouss Logic, all rights reserved.
*
*************************************************************/
+
+typedef QWordType TTFFontRef;
+
+/// @brief Loads a new font into app's memory.
+/// @param name
+/// @return
+CA_EXTERN_C TTFFontRef CreateFont(const char* name);
+
+/// @brief Dispose an allocated font.
+/// @param fon
+/// @return
+CA_EXTERN_C VoidType DisposeFont(TTFFontRef fon); \ No newline at end of file
diff --git a/Public/Developer/System.Core/Headers/Window.hxx b/Public/Developer/System.Core/Headers/Window.hxx
index 02be0681..b7671661 100644
--- a/Public/Developer/System.Core/Headers/Window.hxx
+++ b/Public/Developer/System.Core/Headers/Window.hxx
@@ -21,7 +21,11 @@
struct _GraphicsPoint;
struct _GraphicsPort;
+#ifdef __SINGLE_PRECISION__
typedef float PositionType;
+#else
+typedef double PositionType;
+#endif
/// @brief A point, can represent the size, position of a window.
typedef struct _GraphicsPoint {
diff --git a/Public/Developer/System.Core/Makefile b/Public/Developer/System.Core/Makefile
index c4a97c30..11e4760f 100644
--- a/Public/Developer/System.Core/Makefile
+++ b/Public/Developer/System.Core/Makefile
@@ -4,7 +4,7 @@
##################################################
CC=x86_64-w64-mingw32-g++
-CCFLAGS=-shared -ffreestanding -nostdlib -fno-rtti -fno-exceptions -std=c++20 -Xlinker --subsystem=17
+CCFLAGS=-shared -ffreestanding -D__SINGLE_PRECISION__ -nostdlib -fno-rtti -fno-exceptions -std=c++20 -Xlinker --subsystem=17
OUTPUT=System.Core.lib
.PHONY: build-core-amd64
diff --git a/Public/Developer/System.Core/Sources/CRT0.cxx b/Public/Developer/System.Core/Sources/CRT0.cxx
index b6fb9de1..244e62d5 100644
--- a/Public/Developer/System.Core/Sources/CRT0.cxx
+++ b/Public/Developer/System.Core/Sources/CRT0.cxx
@@ -7,7 +7,7 @@
/// @brief Inits the library.
/// @return if it was succesful or not.
CA_EXTERN_C DWordType __start(VoidType) {
- kApplicationObject = HcGetAppObject();
+ kApplicationObject = RtGetAppObject();
CA_MUST_PASS(kApplicationObject);
return 0;
diff --git a/Public/Developer/System.Core/Sources/Heap.cxx b/Public/Developer/System.Core/Sources/Heap.cxx
index fcd80a7f..991987ca 100644
--- a/Public/Developer/System.Core/Sources/Heap.cxx
+++ b/Public/Developer/System.Core/Sources/Heap.cxx
@@ -11,7 +11,7 @@
/// @param sz size of object.
/// @param flags flags.
/// @return
-CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectRef refObj, QWordType sz,
+CA_EXTERN_C PtrVoidType RtAllocateProcessHeap(ObjectRef refObj, QWordType sz,
DWordType flags) {
CA_MUST_PASS(sz);
CA_MUST_PASS(flags);
@@ -22,7 +22,7 @@ CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectRef refObj, QWordType sz,
/// @brief Free pointer from the user's heap.
/// @param refObj Process object.
/// @param ptr the pointer to free.
-CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr) {
+CA_EXTERN_C VoidType RtFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr) {
CA_MUST_PASS(ptr);
CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr));
}
@@ -31,7 +31,7 @@ CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectRef refObj, PtrVoidType ptr) {
/// @param refObj Process object.
/// @param ptr the pointer to find.
/// @return the size.
-CA_EXTERN_C QWordType HcProcessHeapSize(ObjectRef refObj, PtrVoidType ptr) {
+CA_EXTERN_C QWordType RtProcessHeapSize(ObjectRef refObj, PtrVoidType ptr) {
CA_MUST_PASS(ptr);
return refObj->Invoke(refObj, kProcessCallSizePtr, ptr);
}
@@ -40,7 +40,7 @@ CA_EXTERN_C QWordType HcProcessHeapSize(ObjectRef refObj, PtrVoidType ptr) {
/// @param refObj Process object.
/// @param ptr the pointer to check.
/// @return if it exists
-CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectRef refObj, PtrVoidType ptr) {
+CA_EXTERN_C BooleanType RtProcessHeapExists(ObjectRef refObj, PtrVoidType ptr) {
CA_MUST_PASS(ptr);
return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr);
}
diff --git a/Public/Developer/System.Core/Sources/New+Delete.cxx b/Public/Developer/System.Core/Sources/New+Delete.cxx
index 6e40aa06..3901aed1 100644
--- a/Public/Developer/System.Core/Sources/New+Delete.cxx
+++ b/Public/Developer/System.Core/Sources/New+Delete.cxx
@@ -11,25 +11,25 @@ typedef SizeType size_t;
void* operator new[](size_t sz) {
if (sz == 0) ++sz;
- return HcAllocateProcessHeap(kApplicationObject, sz, kStandardAllocation);
+ return RtAllocateProcessHeap(kApplicationObject, sz, kStandardAllocation);
}
void* operator new(size_t sz) {
if (sz == 0) ++sz;
- return HcAllocateProcessHeap(kApplicationObject, sz, kArrayAllocation);
+ return RtAllocateProcessHeap(kApplicationObject, sz, kArrayAllocation);
}
void operator delete[](void* ptr) {
if (ptr == nullptr) return;
- HcFreeProcessHeap(kApplicationObject, ptr);
+ RtFreeProcessHeap(kApplicationObject, ptr);
}
void operator delete(void* ptr) {
if (ptr == nullptr) return;
- HcFreeProcessHeap(kApplicationObject, ptr);
+ RtFreeProcessHeap(kApplicationObject, ptr);
}
void operator delete(void* ptr, size_t sz) {
@@ -37,5 +37,5 @@ void operator delete(void* ptr, size_t sz) {
(void)sz;
- HcFreeProcessHeap(kApplicationObject, ptr);
+ RtFreeProcessHeap(kApplicationObject, ptr);
}