From 3f3b636caf79424220060f977613e893de63ecb3 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 7 Jan 2023 20:14:44 +0200 Subject: [PATCH] Updated driver loading --- Core/Driver/Driver.cpp | 6 ++++-- Core/Driver/DriverLoading/BindInput.cpp | 2 +- Core/Driver/DriverLoading/BindInterrupt.cpp | 4 ++-- Core/Driver/DriverLoading/BindPCI.cpp | 12 +++++++++--- include/driver.hpp | 1 + 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Core/Driver/Driver.cpp b/Core/Driver/Driver.cpp index 4a38233..2783052 100644 --- a/Core/Driver/Driver.cpp +++ b/Core/Driver/Driver.cpp @@ -181,9 +181,11 @@ namespace Driver uintptr_t ret = this->LoadDriver(driver->Address, driver->Length); char RetString[128]; if (ret == DriverCode::OK) - strncpy(RetString, "\e058C19OK", 64); + strncpy(RetString, "\e058C19OK", 10); + else if (ret == DriverCode::NOT_AVAILABLE) + strncpy(RetString, "\eFF7900NOT AVAILABLE", 21); else - sprintf_(RetString, "\eE85230FAILED (%#lx)", ret); + sprintf(RetString, "\eE85230FAILED (%#lx)", ret); KPrint("%s %s", driver->Name, RetString); } } diff --git a/Core/Driver/DriverLoading/BindInput.cpp b/Core/Driver/DriverLoading/BindInput.cpp index c87e562..7dbdefd 100644 --- a/Core/Driver/DriverLoading/BindInput.cpp +++ b/Core/Driver/DriverLoading/BindInput.cpp @@ -53,7 +53,7 @@ namespace Driver if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED) { delete MemMgr; - error("Driver %s does not implement the configuration callback", fexExtended->Driver.Name); + error("Driver %s is not implemented", fexExtended->Driver.Name); break; } else if (CallbackRet != DriverReturnCode::OK) diff --git a/Core/Driver/DriverLoading/BindInterrupt.cpp b/Core/Driver/DriverLoading/BindInterrupt.cpp index 4208cf0..e4af974 100644 --- a/Core/Driver/DriverLoading/BindInterrupt.cpp +++ b/Core/Driver/DriverLoading/BindInterrupt.cpp @@ -83,7 +83,7 @@ namespace Driver int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(KCallback); if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED) { - error("Driver %s does not implement the configuration callback", fexExtended->Driver.Name); + error("Driver %s is not implemented", fexExtended->Driver.Name); delete MemMgr; break; } @@ -130,7 +130,7 @@ namespace Driver int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(KCallback); if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED) { - error("Driver %s does not implement the configuration callback", fexExtended->Driver.Name); + error("Driver %s is not implemented", fexExtended->Driver.Name); delete InterruptHook; delete MemMgr; break; diff --git a/Core/Driver/DriverLoading/BindPCI.cpp b/Core/Driver/DriverLoading/BindPCI.cpp index 7c28283..2cd9a5a 100644 --- a/Core/Driver/DriverLoading/BindPCI.cpp +++ b/Core/Driver/DriverLoading/BindPCI.cpp @@ -17,6 +17,7 @@ namespace Driver DriverCode Driver::DriverLoadBindPCI(void *DrvExtHdr, uintptr_t DriverAddress, size_t Size, bool IsElf) { UNUSED(IsElf); + bool IsDriverLoaded = false; 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++) { @@ -29,6 +30,7 @@ namespace Driver 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); @@ -106,7 +108,7 @@ namespace Driver int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(KCallback); if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED) { - error("Driver %s does not implement the configuration callback", fexExtended->Driver.Name); + error("Driver %s is not implemented", fexExtended->Driver.Name); delete MemMgr; delete InterruptHook; continue; @@ -138,7 +140,7 @@ namespace Driver int CallbackRet = ((int (*)(KernelCallback *))((uintptr_t)fexExtended->Driver.Callback + (uintptr_t)fex))(KCallback); if (CallbackRet == DriverReturnCode::NOT_IMPLEMENTED) { - error("Driver %s does not implement the configuration callback", fexExtended->Driver.Name); + error("Driver %s is not implemented", fexExtended->Driver.Name); delete MemMgr; continue; } @@ -183,9 +185,13 @@ namespace Driver break; } } + IsDriverLoaded = true; } } - return DriverCode::OK; + if (IsDriverLoaded) + return DriverCode::OK; + else + return DriverCode::NOT_AVAILABLE; } } diff --git a/include/driver.hpp b/include/driver.hpp index 1a9040a..0629b43 100644 --- a/include/driver.hpp +++ b/include/driver.hpp @@ -15,6 +15,7 @@ namespace Driver { ERROR, OK, + NOT_AVAILABLE, INVALID_FEX_HEADER, INVALID_DRIVER_DATA, NOT_DRIVER,