diff --git a/Core/Driver/DriverLoading/BindInput.cpp b/Core/Driver/DriverBinding/BindInput.cpp
similarity index 55%
rename from Core/Driver/DriverLoading/BindInput.cpp
rename to Core/Driver/DriverBinding/BindInput.cpp
index 084030b..b93d02a 100644
--- a/Core/Driver/DriverLoading/BindInput.cpp
+++ b/Core/Driver/DriverBinding/BindInput.cpp
@@ -31,70 +31,6 @@
namespace Driver
{
- DriverCode Driver::BindInputGeneric(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindInputDisplay(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindInputNetwork(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindInputStorage(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindInputFileSystem(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindInputInput(Memory::MemMgr *mem, void *fex)
- {
- FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
- KernelCallback *KCallback = (KernelCallback *)mem->RequestPages(TO_PAGES(sizeof(KernelCallback) + 1));
-
- fixme("Input driver: %s", fexExtended->Driver.Name);
- KCallback->RawPtr = nullptr;
- KCallback->Reason = CallbackReason::ConfigurationReason;
- int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(KCallback);
- if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
- {
- delete mem, mem = nullptr;
- error("Driver %s is not implemented", fexExtended->Driver.Name);
- return DriverCode::NOT_IMPLEMENTED;
- }
- else if (CallbackRet != DriverReturnCode::OK)
- {
- delete mem, mem = nullptr;
- error("Driver %s returned error %d", fexExtended->Driver.Name, CallbackRet);
- return DriverCode::DRIVER_RETURNED_ERROR;
- }
-
- fixme("Input driver: %s", fexExtended->Driver.Name);
-
- DriverFile DrvFile = {
- .Enabled = true,
- .DriverUID = this->DriverUIDs - 1,
- .Address = (void *)fex,
- .MemTrk = mem,
- };
- Drivers.push_back(DrvFile);
- return DriverCode::OK;
- }
-
- DriverCode Driver::BindInputAudio(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
DriverCode Driver::DriverLoadBindInput(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf)
{
UNUSED(DrvExtHdr);
diff --git a/Core/Driver/DriverBinding/BindInterrupt.cpp b/Core/Driver/DriverBinding/BindInterrupt.cpp
new file mode 100644
index 0000000..0af2ab5
--- /dev/null
+++ b/Core/Driver/DriverBinding/BindInterrupt.cpp
@@ -0,0 +1,84 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../kernel.h"
+#include "../../../DAPI.hpp"
+#include "../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::DriverLoadBindInterrupt(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf)
+ {
+ UNUSED(IsElf);
+ Memory::MemMgr *mem = new Memory::MemMgr(nullptr, TaskManager->GetCurrentProcess()->memDirectory);
+ Fex *fex = (Fex *)mem->RequestPages(TO_PAGES(Size + 1));
+ memcpy(fex, (void *)DriverAddress, Size);
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+ debug("Driver allocated at %#lx-%#lx", fex, (uintptr_t)fex + Size);
+#ifdef DEBUG
+ uint8_t *result = md5File((uint8_t *)fex, Size);
+ debug("MD5: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7],
+ result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15]);
+ kfree(result);
+#endif
+ KernelAPI *KAPI = (KernelAPI *)mem->RequestPages(TO_PAGES(sizeof(KernelAPI) + 1));
+
+ if (CallDriverEntryPoint(fex, KAPI) != DriverCode::OK)
+ {
+ delete mem, mem = nullptr;
+ return DriverCode::DRIVER_RETURNED_ERROR;
+ }
+ debug("Starting driver %s (offset: %#lx)", fexExtended->Driver.Name, fex);
+
+ switch (fexExtended->Driver.Type)
+ {
+ case FexDriverType::FexDriverType_Generic:
+ return BindInterruptGeneric(mem, fex);
+ case FexDriverType::FexDriverType_Display:
+ return BindInterruptDisplay(mem, fex);
+ case FexDriverType::FexDriverType_Network:
+ return BindInterruptNetwork(mem, fex);
+ case FexDriverType::FexDriverType_Storage:
+ return BindInterruptStorage(mem, fex);
+ case FexDriverType::FexDriverType_FileSystem:
+ return BindInterruptFileSystem(mem, fex);
+ case FexDriverType::FexDriverType_Input:
+ return BindInterruptInput(mem, fex);
+ case FexDriverType::FexDriverType_Audio:
+ return BindInterruptAudio(mem, fex);
+ default:
+ {
+ warn("Unknown driver type: %d", fexExtended->Driver.Type);
+ delete mem, mem = nullptr;
+ return DriverCode::UNKNOWN_DRIVER_TYPE;
+ }
+ }
+
+ return DriverCode::OK;
+ }
+}
diff --git a/Core/Driver/DriverBinding/BindPCI.cpp b/Core/Driver/DriverBinding/BindPCI.cpp
new file mode 100644
index 0000000..feb5efb
--- /dev/null
+++ b/Core/Driver/DriverBinding/BindPCI.cpp
@@ -0,0 +1,206 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../kernel.h"
+#include "../../../DAPI.hpp"
+#include "../../../Fex.hpp"
+
+namespace Driver
+{
+ void Driver::MapPCIAddresses(PCI::PCIDeviceHeader *PCIDevice)
+ {
+ debug("Header Type: %d", PCIDevice->HeaderType);
+ switch (PCIDevice->HeaderType)
+ {
+ case 0: // PCI Header 0
+ {
+ uint32_t BAR[6] = {0};
+ size_t BARsSize[6] = {0};
+
+ BAR[0] = ((PCI::PCIHeader0 *)PCIDevice)->BAR0;
+ BAR[1] = ((PCI::PCIHeader0 *)PCIDevice)->BAR1;
+ BAR[2] = ((PCI::PCIHeader0 *)PCIDevice)->BAR2;
+ BAR[3] = ((PCI::PCIHeader0 *)PCIDevice)->BAR3;
+ BAR[4] = ((PCI::PCIHeader0 *)PCIDevice)->BAR4;
+ BAR[5] = ((PCI::PCIHeader0 *)PCIDevice)->BAR5;
+
+ uintptr_t BAR_Type = BAR[0] & 1;
+ uintptr_t BAR_IOBase = BAR[1] & (~3);
+ uintptr_t BAR_MemoryBase = BAR[0] & (~15);
+
+ debug("Type: %d; IOBase: %#lx; MemoryBase: %#lx", BAR_Type, BAR_IOBase, BAR_MemoryBase);
+
+ for (size_t i = 0; i < 6; i++)
+ {
+ if (BAR[i] == 0)
+ continue;
+ debug("BAR%d: %#lx", i, BAR[i]);
+ }
+
+ /* BARs Size */
+ for (size_t i = 0; i < 6; i++)
+ {
+ if (BAR[i] == 0)
+ continue;
+
+ if ((BAR[i] & 1) == 0) // Memory Base
+ {
+ ((PCI::PCIHeader0 *)PCIDevice)->BAR0 = 0xFFFFFFFF;
+ size_t size = ((PCI::PCIHeader0 *)PCIDevice)->BAR0;
+ ((PCI::PCIHeader0 *)PCIDevice)->BAR0 = BAR[i];
+ BARsSize[i] = size & (~15);
+ BARsSize[i] = ~BARsSize[i] + 1;
+ BARsSize[i] = BARsSize[i] & 0xFFFFFFFF;
+ debug("BAR%dSize: %#lx", i, BARsSize[i]);
+ }
+ else if ((BAR[i] & 1) == 1) // I/O Base
+ {
+ ((PCI::PCIHeader0 *)PCIDevice)->BAR1 = 0xFFFFFFFF;
+ size_t size = ((PCI::PCIHeader0 *)PCIDevice)->BAR1;
+ ((PCI::PCIHeader0 *)PCIDevice)->BAR1 = BAR[i];
+ BARsSize[i] = size & (~3);
+ BARsSize[i] = ~BARsSize[i] + 1;
+ BARsSize[i] = BARsSize[i] & 0xFFFF;
+ debug("BAR%dSize: %#lx", i, BARsSize[i]);
+ }
+ }
+
+ /* Mapping the BARs */
+ for (size_t i = 0; i < 6; i++)
+ {
+ if (BAR[i] == 0)
+ continue;
+
+ if ((BAR[i] & 1) == 0) // Memory Base
+ {
+ uintptr_t BARBase = BAR[i] & (~15);
+ size_t BARSize = BARsSize[i];
+
+ debug("Mapping BAR%d from %#lx to %#lx", i, BARBase, BARBase + BARSize);
+ Memory::Virtual().Map((void *)BARBase, (void *)BARBase, BARSize, Memory::PTFlag::RW | Memory::PTFlag::PWT);
+ }
+ else if ((BAR[i] & 1) == 1) // I/O Base
+ {
+ uintptr_t BARBase = BAR[i] & (~3);
+ uintptr_t BARSize = BARsSize[i];
+
+ debug("Mapping BAR%d from %#x to %#x", i, BARBase, BARBase + BARSize);
+ Memory::Virtual().Map((void *)BARBase, (void *)BARBase, BARSize, Memory::PTFlag::RW | Memory::PTFlag::PWT);
+ }
+ }
+ break;
+ }
+ case 1: // PCI Header 1 (PCI-to-PCI Bridge)
+ {
+ fixme("PCI Header 1 (PCI-to-PCI Bridge) not implemented yet");
+ break;
+ }
+ case 2: // PCI Header 2 (PCI-to-CardBus Bridge)
+ {
+ fixme("PCI Header 2 (PCI-to-CardBus Bridge) not implemented yet");
+ break;
+ }
+ default:
+ {
+ error("Unknown header type %d", PCIDevice->HeaderType);
+ return;
+ }
+ }
+ }
+
+ DriverCode Driver::DriverLoadBindPCI(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf)
+ {
+ UNUSED(IsElf);
+ for (unsigned long Vidx = 0; Vidx < sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.VendorID) / sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.VendorID[0]); Vidx++)
+ {
+ for (unsigned long Didx = 0; Didx < sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.DeviceID) / sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.DeviceID[0]); Didx++)
+ {
+ if (Vidx >= sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.VendorID) && Didx >= sizeof(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.DeviceID))
+ break;
+
+ if (((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.VendorID[Vidx] == 0 || ((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.DeviceID[Didx] == 0)
+ continue;
+
+ std::vector devices = PCIManager->FindPCIDevice(((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.VendorID[Vidx], ((FexExtended *)DrvExtHdr)->Driver.Bind.PCI.DeviceID[Didx]);
+ if (devices.size() == 0)
+ continue;
+
+ foreach (auto PCIDevice in devices)
+ {
+ debug("[%ld] VendorID: %#x; DeviceID: %#x", devices.size(), PCIDevice->VendorID, PCIDevice->DeviceID);
+ Memory::MemMgr *mem = new Memory::MemMgr(nullptr, TaskManager->GetCurrentProcess()->memDirectory);
+ Fex *fex = (Fex *)mem->RequestPages(TO_PAGES(Size + 1));
+ memcpy(fex, (void *)DriverAddress, Size);
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+ debug("Driver allocated at %#lx-%#lx", fex, (uintptr_t)fex + Size);
+#ifdef DEBUG
+ uint8_t *result = md5File((uint8_t *)fex, Size);
+ debug("MD5: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+ result[0], result[1], result[2], result[3], result[4], result[5], result[6], result[7],
+ result[8], result[9], result[10], result[11], result[12], result[13], result[14], result[15]);
+ kfree(result);
+#endif
+ KernelAPI *KAPI = (KernelAPI *)mem->RequestPages(TO_PAGES(sizeof(KernelAPI) + 1));
+
+ if (CallDriverEntryPoint(fex, KAPI) != DriverCode::OK)
+ {
+ delete mem, mem = nullptr;
+ return DriverCode::DRIVER_RETURNED_ERROR;
+ }
+ debug("Starting driver %s", fexExtended->Driver.Name);
+
+ MapPCIAddresses(PCIDevice);
+
+ switch (fexExtended->Driver.Type)
+ {
+ case FexDriverType::FexDriverType_Generic:
+ return BindPCIGeneric(mem, fex, PCIDevice);
+ case FexDriverType::FexDriverType_Display:
+ return BindPCIDisplay(mem, fex, PCIDevice);
+ case FexDriverType::FexDriverType_Network:
+ return BindPCINetwork(mem, fex, PCIDevice);
+ case FexDriverType::FexDriverType_Storage:
+ return BindPCIStorage(mem, fex, PCIDevice);
+ case FexDriverType::FexDriverType_FileSystem:
+ return BindPCIFileSystem(mem, fex, PCIDevice);
+ case FexDriverType::FexDriverType_Input:
+ return BindPCIInput(mem, fex, PCIDevice);
+ case FexDriverType::FexDriverType_Audio:
+ return BindPCIAudio(mem, fex, PCIDevice);
+ default:
+ {
+ warn("Unknown driver type: %d", fexExtended->Driver.Type);
+ delete mem, mem = nullptr;
+ return DriverCode::UNKNOWN_DRIVER_TYPE;
+ }
+ }
+ }
+ }
+ }
+ return DriverCode::PCI_DEVICE_NOT_FOUND;
+ }
+}
diff --git a/Core/Driver/DriverLoading/BindProcess.cpp b/Core/Driver/DriverBinding/BindProcess.cpp
similarity index 58%
rename from Core/Driver/DriverLoading/BindProcess.cpp
rename to Core/Driver/DriverBinding/BindProcess.cpp
index 12c9f14..98cadbf 100644
--- a/Core/Driver/DriverLoading/BindProcess.cpp
+++ b/Core/Driver/DriverBinding/BindProcess.cpp
@@ -31,41 +31,6 @@
namespace Driver
{
- DriverCode Driver::BindProcessGeneric(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindProcessDisplay(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindProcessNetwork(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindProcessStorage(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindProcessFileSystem(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindProcessInput(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindProcessAudio(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED;
- }
-
DriverCode Driver::DriverLoadBindProcess(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf)
{
fixme("Process driver: %s", ((FexExtended *)DrvExtHdr)->Driver.Name);
diff --git a/Core/Driver/DriverBinding/Input/Audio.cpp b/Core/Driver/DriverBinding/Input/Audio.cpp
new file mode 100644
index 0000000..6429ef7
--- /dev/null
+++ b/Core/Driver/DriverBinding/Input/Audio.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInputAudio(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Input/Display.cpp b/Core/Driver/DriverBinding/Input/Display.cpp
new file mode 100644
index 0000000..4871144
--- /dev/null
+++ b/Core/Driver/DriverBinding/Input/Display.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInputDisplay(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Input/Filesystem.cpp b/Core/Driver/DriverBinding/Input/Filesystem.cpp
new file mode 100644
index 0000000..e3f4a57
--- /dev/null
+++ b/Core/Driver/DriverBinding/Input/Filesystem.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInputFileSystem(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Input/Generic.cpp b/Core/Driver/DriverBinding/Input/Generic.cpp
new file mode 100644
index 0000000..2143210
--- /dev/null
+++ b/Core/Driver/DriverBinding/Input/Generic.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInputGeneric(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Input/Input.cpp b/Core/Driver/DriverBinding/Input/Input.cpp
new file mode 100644
index 0000000..1116904
--- /dev/null
+++ b/Core/Driver/DriverBinding/Input/Input.cpp
@@ -0,0 +1,67 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInputInput(Memory::MemMgr *mem, void *fex)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+ KernelCallback KCallback{};
+
+ fixme("Input driver: %s", fexExtended->Driver.Name);
+ KCallback.RawPtr = nullptr;
+ KCallback.Reason = CallbackReason::ConfigurationReason;
+ int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(&KCallback);
+ if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
+ {
+ delete mem, mem = nullptr;
+ error("Driver %s is not implemented", fexExtended->Driver.Name);
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+ else if (CallbackRet != DriverReturnCode::OK)
+ {
+ delete mem, mem = nullptr;
+ error("Driver %s returned error %d", fexExtended->Driver.Name, CallbackRet);
+ return DriverCode::DRIVER_RETURNED_ERROR;
+ }
+
+ fixme("Input driver: %s", fexExtended->Driver.Name);
+
+ DriverFile DrvFile = {
+ .Enabled = true,
+ .DriverUID = this->DriverUIDs - 1,
+ .Address = (void *)fex,
+ .MemTrk = mem,
+ };
+ Drivers.push_back(DrvFile);
+ return DriverCode::OK;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Input/Network.cpp b/Core/Driver/DriverBinding/Input/Network.cpp
new file mode 100644
index 0000000..8fdb103
--- /dev/null
+++ b/Core/Driver/DriverBinding/Input/Network.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInputNetwork(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Input/Storage.cpp b/Core/Driver/DriverBinding/Input/Storage.cpp
new file mode 100644
index 0000000..30a6082
--- /dev/null
+++ b/Core/Driver/DriverBinding/Input/Storage.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInputStorage(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Interrupt/Audio.cpp b/Core/Driver/DriverBinding/Interrupt/Audio.cpp
new file mode 100644
index 0000000..bdf20d3
--- /dev/null
+++ b/Core/Driver/DriverBinding/Interrupt/Audio.cpp
@@ -0,0 +1,81 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInterruptAudio(Memory::MemMgr *mem, void *fex)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ fixme("Audio driver: %s", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Interrupt/Display.cpp b/Core/Driver/DriverBinding/Interrupt/Display.cpp
new file mode 100644
index 0000000..8db0960
--- /dev/null
+++ b/Core/Driver/DriverBinding/Interrupt/Display.cpp
@@ -0,0 +1,81 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInterruptDisplay(Memory::MemMgr *mem, void *fex)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ fixme("Display driver: %s", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Interrupt/Filesystem.cpp b/Core/Driver/DriverBinding/Interrupt/Filesystem.cpp
new file mode 100644
index 0000000..751920a
--- /dev/null
+++ b/Core/Driver/DriverBinding/Interrupt/Filesystem.cpp
@@ -0,0 +1,81 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInterruptFileSystem(Memory::MemMgr *mem, void *fex)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ fixme("Filesystem driver: %s", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Interrupt/Generic.cpp b/Core/Driver/DriverBinding/Interrupt/Generic.cpp
new file mode 100644
index 0000000..1a01cbd
--- /dev/null
+++ b/Core/Driver/DriverBinding/Interrupt/Generic.cpp
@@ -0,0 +1,88 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInterruptGeneric(Memory::MemMgr *mem, void *fex)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ fixme("Generic driver: %s", fexExtended->Driver.Name);
+ DriverFile DrvFile = {
+ .Enabled = true,
+ .DriverUID = this->DriverUIDs - 1,
+ .Address = (void *)fex,
+ .InterruptCallback = (void *)((uintptr_t)fex + (uintptr_t)fexExtended->Driver.InterruptCallback),
+ .MemTrk = mem,
+ };
+ Drivers.push_back(DrvFile);
+ return DriverCode::OK;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Interrupt/Input.cpp b/Core/Driver/DriverBinding/Interrupt/Input.cpp
new file mode 100644
index 0000000..520630f
--- /dev/null
+++ b/Core/Driver/DriverBinding/Interrupt/Input.cpp
@@ -0,0 +1,124 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInterruptInput(Memory::MemMgr *mem, void *fex)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ debug("Searching for conflicting drivers...");
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if ((fe->Driver.TypeFlags & FexDriverInputTypes_Mouse &&
+ fexExtended->Driver.TypeFlags & FexDriverInputTypes_Mouse) ||
+ (fe->Driver.TypeFlags & FexDriverInputTypes_Keyboard &&
+ fexExtended->Driver.TypeFlags & FexDriverInputTypes_Keyboard))
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ if (fe->Driver.OverrideOnConflict)
+ return DriverCode::DRIVER_CONFLICT;
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if ((fe->Driver.TypeFlags & FexDriverInputTypes_Mouse &&
+ fexExtended->Driver.TypeFlags & FexDriverInputTypes_Mouse) ||
+ (fe->Driver.TypeFlags & FexDriverInputTypes_Keyboard &&
+ fexExtended->Driver.TypeFlags & FexDriverInputTypes_Keyboard))
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ if (fe->Driver.OverrideOnConflict)
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ DriverFile DrvFile = {
+ .Enabled = true,
+ .DriverUID = this->DriverUIDs - 1,
+ .Address = (void *)fex,
+ .InterruptCallback = (void *)((uintptr_t)fex + (uintptr_t)fexExtended->Driver.InterruptCallback),
+ .MemTrk = mem,
+ };
+ if (fexExtended->Driver.InterruptCallback)
+ {
+ for (unsigned long i = 0; i < sizeof(fexExtended->Driver.Bind.Interrupt.Vector) / sizeof(fexExtended->Driver.Bind.Interrupt.Vector[0]); i++)
+ {
+ if (fexExtended->Driver.Bind.Interrupt.Vector[i] == 0)
+ break;
+ DrvFile.InterruptHook[i] = new DriverInterruptHook(fexExtended->Driver.Bind.Interrupt.Vector[i], DrvFile);
+ }
+ }
+
+ KernelCallback KCallback{};
+ KCallback.RawPtr = nullptr;
+ KCallback.Reason = CallbackReason::ConfigurationReason;
+ int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(&KCallback);
+
+ if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
+ {
+ error("Driver %s is not implemented", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+ else if (CallbackRet != DriverReturnCode::OK)
+ {
+ error("Driver %s returned error %d", fexExtended->Driver.Name, CallbackRet);
+ delete mem, mem = nullptr;
+ return DriverCode::DRIVER_RETURNED_ERROR;
+ }
+
+ Drivers.push_back(DrvFile);
+ return DriverCode::OK;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Interrupt/Network.cpp b/Core/Driver/DriverBinding/Interrupt/Network.cpp
new file mode 100644
index 0000000..8e71893
--- /dev/null
+++ b/Core/Driver/DriverBinding/Interrupt/Network.cpp
@@ -0,0 +1,81 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInterruptNetwork(Memory::MemMgr *mem, void *fex)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ fixme("Network driver: %s", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Interrupt/Storage.cpp b/Core/Driver/DriverBinding/Interrupt/Storage.cpp
new file mode 100644
index 0000000..470cf71
--- /dev/null
+++ b/Core/Driver/DriverBinding/Interrupt/Storage.cpp
@@ -0,0 +1,115 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindInterruptStorage(Memory::MemMgr *mem, void *fex)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ DriverFile DrvFile = {
+ .Enabled = true,
+ .DriverUID = this->DriverUIDs - 1,
+ .Address = (void *)fex,
+ .InterruptCallback = (void *)((uintptr_t)fex + (uintptr_t)fexExtended->Driver.InterruptCallback),
+ .MemTrk = mem,
+ };
+ if (fexExtended->Driver.InterruptCallback)
+ {
+ for (unsigned long i = 0; i < sizeof(fexExtended->Driver.Bind.Interrupt.Vector) / sizeof(fexExtended->Driver.Bind.Interrupt.Vector[0]); i++)
+ {
+ if (fexExtended->Driver.Bind.Interrupt.Vector[i] == 0)
+ break;
+ DrvFile.InterruptHook[i] = new DriverInterruptHook(fexExtended->Driver.Bind.Interrupt.Vector[i], DrvFile);
+ }
+ }
+
+ KernelCallback KCallback{};
+ KCallback.RawPtr = nullptr;
+ KCallback.Reason = CallbackReason::ConfigurationReason;
+ int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(&KCallback);
+
+ if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
+ {
+ error("Driver %s is not implemented", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+ else if (CallbackRet != DriverReturnCode::OK)
+ {
+ error("Driver %s returned error %d", fexExtended->Driver.Name, CallbackRet);
+ delete mem, mem = nullptr;
+ return DriverCode::DRIVER_RETURNED_ERROR;
+ }
+
+ Drivers.push_back(DrvFile);
+ return DriverCode::OK;
+ }
+}
diff --git a/Core/Driver/DriverBinding/PCI/Audio.cpp b/Core/Driver/DriverBinding/PCI/Audio.cpp
new file mode 100644
index 0000000..1e65757
--- /dev/null
+++ b/Core/Driver/DriverBinding/PCI/Audio.cpp
@@ -0,0 +1,110 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindPCIAudio(Memory::MemMgr *mem, void *fex, PCI::PCIDeviceHeader *PCIDevice)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ DriverFile DrvFile = {
+ .Enabled = true,
+ .DriverUID = this->DriverUIDs - 1,
+ .Address = (void *)fex,
+ .InterruptCallback = (void *)((uintptr_t)fex + (uintptr_t)fexExtended->Driver.InterruptCallback),
+ .MemTrk = mem,
+ };
+ if (fexExtended->Driver.InterruptCallback)
+ DrvFile.InterruptHook[0] = new DriverInterruptHook(((int)((PCI::PCIHeader0 *)PCIDevice)->InterruptLine), DrvFile);
+
+ KernelCallback KCallback{};
+ KCallback.RawPtr = PCIDevice;
+ KCallback.Reason = CallbackReason::ConfigurationReason;
+ int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(&KCallback);
+
+ if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
+ {
+ error("Driver %s is not implemented", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+ else if (CallbackRet == DriverReturnCode::OK)
+ trace("Device found for driver: %s", fexExtended->Driver.Name);
+ else
+ {
+ error("Driver %s returned error %d", fexExtended->Driver.Name, CallbackRet);
+ delete mem, mem = nullptr;
+ return DriverCode::DRIVER_RETURNED_ERROR;
+ }
+
+ Drivers.push_back(DrvFile);
+ return DriverCode::OK;
+ }
+}
diff --git a/Core/Driver/DriverBinding/PCI/Display.cpp b/Core/Driver/DriverBinding/PCI/Display.cpp
new file mode 100644
index 0000000..5218d5b
--- /dev/null
+++ b/Core/Driver/DriverBinding/PCI/Display.cpp
@@ -0,0 +1,81 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindPCIDisplay(Memory::MemMgr *mem, void *fex, PCI::PCIDeviceHeader *PCIDevice)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ fixme("Display driver: %s", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/PCI/Filesystem.cpp b/Core/Driver/DriverBinding/PCI/Filesystem.cpp
new file mode 100644
index 0000000..170115e
--- /dev/null
+++ b/Core/Driver/DriverBinding/PCI/Filesystem.cpp
@@ -0,0 +1,81 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindPCIFileSystem(Memory::MemMgr *mem, void *fex, PCI::PCIDeviceHeader *PCIDevice)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ fixme("Filesystem driver: %s", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/PCI/Generic.cpp b/Core/Driver/DriverBinding/PCI/Generic.cpp
new file mode 100644
index 0000000..136a695
--- /dev/null
+++ b/Core/Driver/DriverBinding/PCI/Generic.cpp
@@ -0,0 +1,81 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindPCIGeneric(Memory::MemMgr *mem, void *fex, PCI::PCIDeviceHeader *PCIDevice)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ fixme("Generic driver: %s", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/PCI/Input.cpp b/Core/Driver/DriverBinding/PCI/Input.cpp
new file mode 100644
index 0000000..4cfbd3d
--- /dev/null
+++ b/Core/Driver/DriverBinding/PCI/Input.cpp
@@ -0,0 +1,81 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindPCIInput(Memory::MemMgr *mem, void *fex, PCI::PCIDeviceHeader *PCIDevice)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ fixme("Input driver: %s", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/PCI/Network.cpp b/Core/Driver/DriverBinding/PCI/Network.cpp
new file mode 100644
index 0000000..5e28fdc
--- /dev/null
+++ b/Core/Driver/DriverBinding/PCI/Network.cpp
@@ -0,0 +1,110 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindPCINetwork(Memory::MemMgr *mem, void *fex, PCI::PCIDeviceHeader *PCIDevice)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ DriverFile DrvFile = {
+ .Enabled = true,
+ .DriverUID = this->DriverUIDs - 1,
+ .Address = (void *)fex,
+ .InterruptCallback = (void *)((uintptr_t)fex + (uintptr_t)fexExtended->Driver.InterruptCallback),
+ .MemTrk = mem,
+ };
+ if (fexExtended->Driver.InterruptCallback)
+ DrvFile.InterruptHook[0] = new DriverInterruptHook(((int)((PCI::PCIHeader0 *)PCIDevice)->InterruptLine), DrvFile);
+
+ KernelCallback KCallback{};
+ KCallback.RawPtr = PCIDevice;
+ KCallback.Reason = CallbackReason::ConfigurationReason;
+ int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(&KCallback);
+
+ if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
+ {
+ error("Driver %s is not implemented", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+ else if (CallbackRet == DriverReturnCode::OK)
+ trace("Device found for driver: %s", fexExtended->Driver.Name);
+ else
+ {
+ error("Driver %s returned error %d", fexExtended->Driver.Name, CallbackRet);
+ delete mem, mem = nullptr;
+ return DriverCode::DRIVER_RETURNED_ERROR;
+ }
+
+ Drivers.push_back(DrvFile);
+ return DriverCode::OK;
+ }
+}
diff --git a/Core/Driver/DriverBinding/PCI/Storage.cpp b/Core/Driver/DriverBinding/PCI/Storage.cpp
new file mode 100644
index 0000000..2e3a3ea
--- /dev/null
+++ b/Core/Driver/DriverBinding/PCI/Storage.cpp
@@ -0,0 +1,110 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindPCIStorage(Memory::MemMgr *mem, void *fex, PCI::PCIDeviceHeader *PCIDevice)
+ {
+ FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
+
+ if (fexExtended->Driver.OverrideOnConflict)
+ {
+ std::vector DriversToRemove = std::vector();
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+
+ DriversToRemove.push_back(Drv.DriverUID);
+ }
+
+ foreach (auto DrvID in DriversToRemove)
+ {
+ if (!this->UnloadDriver(DrvID))
+ {
+ error("Failed to unload conflicting driver %d", DrvID);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+ else
+ {
+ foreach (auto Drv in Drivers)
+ {
+ FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
+
+ if (fe->Driver.OverrideOnConflict)
+ {
+ debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
+ return DriverCode::DRIVER_CONFLICT;
+ }
+ }
+ }
+
+ DriverFile DrvFile = {
+ .Enabled = true,
+ .DriverUID = this->DriverUIDs - 1,
+ .Address = (void *)fex,
+ .InterruptCallback = (void *)((uintptr_t)fex + (uintptr_t)fexExtended->Driver.InterruptCallback),
+ .MemTrk = mem,
+ };
+ if (fexExtended->Driver.InterruptCallback)
+ DrvFile.InterruptHook[0] = new DriverInterruptHook(((int)((PCI::PCIHeader0 *)PCIDevice)->InterruptLine), DrvFile);
+
+ KernelCallback KCallback{};
+ KCallback.RawPtr = PCIDevice;
+ KCallback.Reason = CallbackReason::ConfigurationReason;
+ int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(&KCallback);
+
+ if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
+ {
+ error("Driver %s is not implemented", fexExtended->Driver.Name);
+ delete mem, mem = nullptr;
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+ else if (CallbackRet == DriverReturnCode::OK)
+ trace("Device found for driver: %s", fexExtended->Driver.Name);
+ else
+ {
+ error("Driver %s returned error %d", fexExtended->Driver.Name, CallbackRet);
+ delete mem, mem = nullptr;
+ return DriverCode::DRIVER_RETURNED_ERROR;
+ }
+
+ Drivers.push_back(DrvFile);
+ return DriverCode::OK;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Process/Audio.cpp b/Core/Driver/DriverBinding/Process/Audio.cpp
new file mode 100644
index 0000000..a3f2cea
--- /dev/null
+++ b/Core/Driver/DriverBinding/Process/Audio.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindProcessAudio(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Process/Display.cpp b/Core/Driver/DriverBinding/Process/Display.cpp
new file mode 100644
index 0000000..e1cab10
--- /dev/null
+++ b/Core/Driver/DriverBinding/Process/Display.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindProcessDisplay(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Process/Filesystem.cpp b/Core/Driver/DriverBinding/Process/Filesystem.cpp
new file mode 100644
index 0000000..9b22682
--- /dev/null
+++ b/Core/Driver/DriverBinding/Process/Filesystem.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindProcessFileSystem(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Process/Generic.cpp b/Core/Driver/DriverBinding/Process/Generic.cpp
new file mode 100644
index 0000000..475f645
--- /dev/null
+++ b/Core/Driver/DriverBinding/Process/Generic.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindProcessGeneric(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Process/Input.cpp b/Core/Driver/DriverBinding/Process/Input.cpp
new file mode 100644
index 0000000..bba2e5a
--- /dev/null
+++ b/Core/Driver/DriverBinding/Process/Input.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindProcessInput(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Process/Network.cpp b/Core/Driver/DriverBinding/Process/Network.cpp
new file mode 100644
index 0000000..ba2aa97
--- /dev/null
+++ b/Core/Driver/DriverBinding/Process/Network.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindProcessNetwork(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverBinding/Process/Storage.cpp b/Core/Driver/DriverBinding/Process/Storage.cpp
new file mode 100644
index 0000000..65d5d4b
--- /dev/null
+++ b/Core/Driver/DriverBinding/Process/Storage.cpp
@@ -0,0 +1,38 @@
+/*
+ This file is part of Fennix Kernel.
+
+ Fennix Kernel is free software: you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of
+ the License, or (at your option) any later version.
+
+ Fennix Kernel is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fennix Kernel. If not, see .
+*/
+
+#include "../../api.hpp"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../../../../kernel.h"
+#include "../../../../DAPI.hpp"
+#include "../../../../Fex.hpp"
+
+namespace Driver
+{
+ DriverCode Driver::BindProcessStorage(Memory::MemMgr *mem, void *fex)
+ {
+ return DriverCode::NOT_IMPLEMENTED;
+ }
+}
diff --git a/Core/Driver/DriverLoading/BindInterrupt.cpp b/Core/Driver/DriverLoading/BindInterrupt.cpp
deleted file mode 100644
index 8c09a4f..0000000
--- a/Core/Driver/DriverLoading/BindInterrupt.cpp
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- This file is part of Fennix Kernel.
-
- Fennix Kernel is free software: you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of
- the License, or (at your option) any later version.
-
- Fennix Kernel is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Fennix Kernel. If not, see .
-*/
-
-#include "../api.hpp"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "../../../kernel.h"
-#include "../../../DAPI.hpp"
-#include "../../../Fex.hpp"
-
-namespace Driver
-{
- DriverCode Driver::BindInterruptGeneric(Memory::MemMgr *mem, void *fex)
- {
- FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
-
- if (fexExtended->Driver.OverrideOnConflict)
- {
- std::vector DriversToRemove = std::vector();
- foreach (auto Drv in Drivers)
- {
- FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
-
- if (fe->Driver.OverrideOnConflict)
- {
- debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
- return DriverCode::DRIVER_CONFLICT;
- }
-
- DriversToRemove.push_back(Drv.DriverUID);
- }
-
- foreach (auto DrvID in DriversToRemove)
- {
- if (!this->UnloadDriver(DrvID))
- {
- error("Failed to unload conflicting driver %d", DrvID);
- return DriverCode::DRIVER_CONFLICT;
- }
- }
- }
- else
- {
- foreach (auto Drv in Drivers)
- {
- FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
-
- if (fe->Driver.OverrideOnConflict)
- {
- debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
- return DriverCode::DRIVER_CONFLICT;
- }
- }
- }
-
- fixme("Generic driver: %s", fexExtended->Driver.Name);
- DriverFile DrvFile = {
- .Enabled = true,
- .DriverUID = this->DriverUIDs - 1,
- .Address = (void *)fex,
- .InterruptCallback = (void *)((uintptr_t)fex + (uintptr_t)fexExtended->Driver.InterruptCallback),
- .MemTrk = mem,
- };
- Drivers.push_back(DrvFile);
- return DriverCode::OK;
- }
-
- DriverCode Driver::BindInterruptDisplay(Memory::MemMgr *mem, void *fex)
- {
- FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
-
- if (fexExtended->Driver.OverrideOnConflict)
- {
- std::vector DriversToRemove = std::vector();
- foreach (auto Drv in Drivers)
- {
- FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
-
- if (fe->Driver.OverrideOnConflict)
- {
- debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
- return DriverCode::DRIVER_CONFLICT;
- }
-
- DriversToRemove.push_back(Drv.DriverUID);
- }
-
- foreach (auto DrvID in DriversToRemove)
- {
- if (!this->UnloadDriver(DrvID))
- {
- error("Failed to unload conflicting driver %d", DrvID);
- return DriverCode::DRIVER_CONFLICT;
- }
- }
- }
- else
- {
- foreach (auto Drv in Drivers)
- {
- FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
-
- if (fe->Driver.OverrideOnConflict)
- {
- debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
- return DriverCode::DRIVER_CONFLICT;
- }
- }
- }
-
- fixme("Display driver: %s", fexExtended->Driver.Name);
- delete mem, mem = nullptr;
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindInterruptNetwork(Memory::MemMgr *mem, void *fex)
- {
- FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
-
- if (fexExtended->Driver.OverrideOnConflict)
- {
- std::vector DriversToRemove = std::vector();
- foreach (auto Drv in Drivers)
- {
- FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
-
- if (fe->Driver.OverrideOnConflict)
- {
- debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
- return DriverCode::DRIVER_CONFLICT;
- }
-
- DriversToRemove.push_back(Drv.DriverUID);
- }
-
- foreach (auto DrvID in DriversToRemove)
- {
- if (!this->UnloadDriver(DrvID))
- {
- error("Failed to unload conflicting driver %d", DrvID);
- return DriverCode::DRIVER_CONFLICT;
- }
- }
- }
- else
- {
- foreach (auto Drv in Drivers)
- {
- FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
-
- if (fe->Driver.OverrideOnConflict)
- {
- debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
- return DriverCode::DRIVER_CONFLICT;
- }
- }
- }
-
- fixme("Network driver: %s", fexExtended->Driver.Name);
- delete mem, mem = nullptr;
- return DriverCode::NOT_IMPLEMENTED;
- }
-
- DriverCode Driver::BindInterruptStorage(Memory::MemMgr *mem, void *fex)
- {
- return DriverCode::NOT_IMPLEMENTED; // FIXME
- FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
-
- if (fexExtended->Driver.OverrideOnConflict)
- {
- std::vector DriversToRemove = std::vector();
- foreach (auto Drv in Drivers)
- {
- FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
-
- if (fe->Driver.OverrideOnConflict)
- {
- debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
- return DriverCode::DRIVER_CONFLICT;
- }
-
- DriversToRemove.push_back(Drv.DriverUID);
- }
-
- foreach (auto DrvID in DriversToRemove)
- {
- if (!this->UnloadDriver(DrvID))
- {
- error("Failed to unload conflicting driver %d", DrvID);
- return DriverCode::DRIVER_CONFLICT;
- }
- }
- }
- else
- {
- foreach (auto Drv in Drivers)
- {
- FexExtended *fe = ((FexExtended *)((uintptr_t)Drv.Address + EXTENDED_SECTION_ADDRESS));
-
- if (fe->Driver.OverrideOnConflict)
- {
- debug("Driver %s is conflicting with %s", fe->Driver.Name, fexExtended->Driver.Name);
- return DriverCode::DRIVER_CONFLICT;
- }
- }
- }
- DriverFile DrvFile = {
- .Enabled = true,
- .DriverUID = this->DriverUIDs - 1,
- .Address = (void *)fex,
- .InterruptCallback = (void *)((uintptr_t)fex + (uintptr_t)fexExtended->Driver.InterruptCallback),
- .MemTrk = mem,
- };
- if (fexExtended->Driver.InterruptCallback)
- {
- for (unsigned long i = 0; i < sizeof(fexExtended->Driver.Bind.Interrupt.Vector) / sizeof(fexExtended->Driver.Bind.Interrupt.Vector[0]); i++)
- {
- if (fexExtended->Driver.Bind.Interrupt.Vector[i] == 0)
- break;
- DrvFile.InterruptHook[i] = new DriverInterruptHook(fexExtended->Driver.Bind.Interrupt.Vector[i], DrvFile);
- }
- }
-
- KernelCallback KCallback = {.raw = 0};
- KCallback.RawPtr = nullptr;
- KCallback.Reason = CallbackReason::ConfigurationReason;
- int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(&KCallback);
-
- if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED)
- {
- error("Driver %s is not implemented", fexExtended->Driver.Name);
- delete mem, mem = nullptr;
- return DriverCode::NOT_IMPLEMENTED;
- }
- else if (CallbackRet != DriverReturnCode::OK)
- {
- error("Driver %s returned error %d", fexExtended->Driver.Name, CallbackRet);
- delete mem, mem = nullptr;
- return DriverCode::DRIVER_RETURNED_ERROR;
- }
-
- Drivers.push_back(DrvFile);
- return DriverCode::OK;
- }
-
- DriverCode Driver::BindInterruptFileSystem(Memory::MemMgr *mem, void *fex)
- {
- FexExtended *fexExtended = (FexExtended *)((uintptr_t)fex + EXTENDED_SECTION_ADDRESS);
-
- if (fexExtended->Driver.OverrideOnConflict)
- {
- std::vector