summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal <amlal.elmahrouss@icloud.com>2025-02-21 08:29:52 +0100
committerAmlal <amlal.elmahrouss@icloud.com>2025-02-21 08:29:52 +0100
commit1517ad3c9d8ee73086365763edd1f3b4d935074d (patch)
tree5da121158e77af795a32f556b0401047cf9718a1 /dev
parent00f4fd8e3ae003d458ea0b6ae47b9ba3c9067bcf (diff)
Moved FB API to GPU.h Add Format, Message and Filesystem API.
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev')
-rw-r--r--dev/Kernel/HALKit/AMD64/Storage/AHCI.cc22
-rw-r--r--dev/LibSCI/GPU.h42
-rw-r--r--dev/LibSCI/Macros.h8
-rw-r--r--dev/LibSCI/SCI.h18
4 files changed, 57 insertions, 33 deletions
diff --git a/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc b/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc
index 7a12e3ca..59163da5 100644
--- a/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc
+++ b/dev/Kernel/HALKit/AMD64/Storage/AHCI.cc
@@ -49,9 +49,9 @@ enum
};
STATIC PCI::Device kPCIDevice;
-STATIC HbaMem* kSATA = nullptr;
-STATIC SizeT kSATAIndex = 0UL;
-STATIC Lba kHighestLBA = 0UL;
+STATIC HbaMem* kSATA = nullptr;
+STATIC SizeT kSATAIndex = 0UL;
+STATIC Lba kHighestLBA = 0UL;
template <BOOL Write, BOOL CommandOrCTRL, BOOL Identify>
STATIC Void drv_std_input_output(UInt64 lba, UInt8* buffer, SizeT sector_sz, SizeT size_buffer) noexcept;
@@ -126,7 +126,7 @@ STATIC Void drv_std_input_output(UInt64 lba, UInt8* buffer, SizeT sector_sz, Siz
command_table->Prdt[0].Dba = ((UInt32)(UInt64)buffer_phys & __UINT32_MAX__);
command_table->Prdt[0].Dbau = (((UInt64)(buffer_phys) >> 32) & __UINT32_MAX__);
- command_table->Prdt[0].Dbc = ((size_buffer) - 1);
+ command_table->Prdt[0].Dbc = ((size_buffer)-1);
command_table->Prdt[0].Ie = YES;
FisRegH2D* h2d_fis = (FisRegH2D*)((UInt64)&command_table->Cfis);
@@ -157,7 +157,7 @@ STATIC Void drv_std_input_output(UInt64 lba, UInt8* buffer, SizeT sector_sz, Siz
}
kSATA->Ports[kSATAIndex].Ci = (1 << slot);
- kAHCICommandIssued = YES;
+ kAHCICommandIssued = YES;
while (kSATA->Ports[kSATAIndex].Ci & (1 << slot))
{
@@ -206,16 +206,16 @@ Bool drv_std_init(UInt16& pi)
{
HbaMem* mem_ahci = (HbaMem*)kPCIDevice.Bar(kSATABar5);
- kPCIDevice.EnableMmio((UInt32)(UIntPtr)mem_ahci); // Enable the memory index_byte/o for this ahci device.
+ kPCIDevice.EnableMmio((UInt32)(UIntPtr)mem_ahci); // Enable the memory index_byte/o for this ahci device.
kPCIDevice.BecomeBusMaster((UInt32)(UIntPtr)mem_ahci); // Become bus master for this ahci device, so that we can control it.
UInt32 ports_implemented = mem_ahci->Pi;
- UInt16 ahci_index = 0;
+ UInt16 ahci_index = 0;
const UInt16 kMaxPortsImplemented = kAhciPortCnt;
- const UInt32 kSATASignature = 0x00000101;
- const UInt8 kAhciPresent = 0x03;
- const UInt8 kAhciIPMActive = 0x01;
+ const UInt32 kSATASignature = 0x00000101;
+ const UInt8 kAhciPresent = 0x03;
+ const UInt8 kAhciIPMActive = 0x01;
Boolean detected = false;
@@ -231,7 +231,7 @@ Bool drv_std_init(UInt16& pi)
kout << "SATA port found.\r";
kSATAIndex = ahci_index;
- kSATA = mem_ahci;
+ kSATA = mem_ahci;
drv_calculate_disk_geometry();
diff --git a/dev/LibSCI/GPU.h b/dev/LibSCI/GPU.h
index 52ae6b1d..bbcd1300 100644
--- a/dev/LibSCI/GPU.h
+++ b/dev/LibSCI/GPU.h
@@ -3,7 +3,7 @@
Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved.
File: GPU.h
-Purpose: GFX System Calls.
+Purpose: GPU/FB System Calls.
------------------------------------------- */
@@ -16,41 +16,57 @@ Purpose: GFX System Calls.
/// @brief GPU API.
/// ------------------------------------------------------------------------------------------ //
-struct GPUCmdBuffer;
+struct GPUCmd;
typedef VoidPtr GPUObject;
/// ------------------------------------------------------------------------------------------ //
-/// @brief Command buffer structure type.
+/// @brief Command structure type.
/// ------------------------------------------------------------------------------------------ //
-struct GPUCmdBuffer final
+
+struct GPUCmd
{
VoidPtr Data{nullptr};
SizeT DataSz{0};
SizeT BufferLayer{0};
- Bool IsGPGPUData{false};
- Bool BufferFirst{false};
+ BOOL IsGPGPUData{NO};
- Bool isGPGPUData()
+ BOOL isGPGPUData()
{
- return this->isValid() && !this->BufferFirst && this->IsGPGPUData;
+ return this->isValid() && this->IsGPGPUData;
}
- Bool isBackBuffer()
+ BOOL isBackBuffer()
{
- return !this->BufferFirst;
+ return this->BufferLayer > 0;
}
- Bool isValid()
+ BOOL isValid()
{
return this->Data && (this->DataSz > 0) && (MmGetHeapFlags(this->Data) != -1);
}
};
-IMPORT_C GPUObject GPUNewFromDeviceName(_Input const Char* device_name);
+IMPORT_C BOOL GPUListDevices(const Char** list, SizeT cnt);
+
+IMPORT_C GPUObject GPUGetFromDeviceName(_Input const Char* device_name);
+
+IMPORT_C GPUObject GPUQueryInfo(_Input const GPUObject* device_name, VoidPtr* out, SizeT out_sz);
IMPORT_C SInt32 GPUDisposeDevice(GPUObject gpu_handle, Bool cancel_all, Bool flush_all);
-IMPORT_C SInt32 GPUSendCmdBufferListWithCnt(GPUCmdBuffer** cmd_list, SizeT cmd_list_cnt);
+IMPORT_C SInt32 GPUSendCmdBufferListWithCnt(GPUCmd** cmd_list, SizeT cmd_list_cnt);
+
+// ------------------------------------------------------------------------------------------ //
+// @brief FB API.
+// ------------------------------------------------------------------------------------------ //
+
+IMPORT_C SInt32 FBAcquireBuffer(GPUObject* out, SInt32 width, SInt32 height);
+
+IMPORT_C SInt32 FBDisposeBuffer(GPUObject* in);
+
+IMPORT_C SInt32 FBGetColorProfile(GPUObject in);
+
+IMPORT_C SInt32 FBQueryInfo(GPUObject handle, VoidPtr* info_ptr, SizeT* info_sz);
#endif // ifndef SCI_GPU_H
diff --git a/dev/LibSCI/Macros.h b/dev/LibSCI/Macros.h
index 92461f3f..ccdfb485 100644
--- a/dev/LibSCI/Macros.h
+++ b/dev/LibSCI/Macros.h
@@ -33,6 +33,14 @@ typedef bool BOOL;
typedef bool Boolean;
typedef void Void;
+#ifndef __cplusplus
+#define true 1
+#define false 0
+#endif
+
+#define YES true
+#define NO false
+
typedef __UINT64_TYPE__ UInt64;
typedef __UINT32_TYPE__ UInt32;
typedef __UINT16_TYPE__ UInt16;
diff --git a/dev/LibSCI/SCI.h b/dev/LibSCI/SCI.h
index 3b03bee2..a7d449d4 100644
--- a/dev/LibSCI/SCI.h
+++ b/dev/LibSCI/SCI.h
@@ -318,17 +318,9 @@ IMPORT_C SInt32 SchedKill(PID, SInt32 req);
IMPORT_C SInt32 SchedBreakPoint(Void);
// ------------------------------------------------------------------------------------------ //
-// @brief Video API.
+// @brief Filesystem API.
// ------------------------------------------------------------------------------------------ //
-IMPORT_C SInt32 VideoGetBuffer(VoidPtr* out);
-
-IMPORT_C SInt32 VideoDisposeBuffer(VoidPtr* in);
-
-IMPORT_C SInt32 VideoGetColorProfile(VoidPtr* in);
-
-IMPORT_C SInt32 VideoQueryInfo(VoidPtr* info_ptr, SizeT* info_sz);
-
IMPORT_C BOOL FsCopy(const char* path, const char* dst);
IMPORT_C BOOL FsMove(const char* path, const char* dst);
@@ -338,8 +330,16 @@ IMPORT_C BOOL FsCreateDir(const char* path);
IMPORT_C BOOL FsCreateFile(const char* path);
IMPORT_C BOOL FsCreateAlias(const char* path, const char* from);
+// ------------------------------------------------------------------------------------------ //
+// @brief Format API.
+// ------------------------------------------------------------------------------------------ //
+
IMPORT_C Char* StrFmt(const Char* fmt, ...);
+// ------------------------------------------------------------------------------------------ //
+// @brief Message API.
+// ------------------------------------------------------------------------------------------ //
+
IMPORT_C SInt32 MsgFree(VoidPtr handle);
IMPORT_C SInt32 MsgShow(VoidPtr handle);